Skip to content

Commit 83e3a49

Browse files
authored
Merge pull request #3 from ABGEO07/develope
Develope
2 parents 96df4a2 + 7981062 commit 83e3a49

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Cherry-request Changelog
22

3-
## [v1.0.0](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.0 "v1.0.0") (2019-03-25)
3+
## [v1.0.1](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.1 "v1.0.1") (2019-03-28)
4+
5+
- Change Namespace
6+
7+
Now you should use new namespace `Cherry\HttpUtils\Request`
8+
9+
- Validate code in PHP CodeSniffer
10+
11+
Code and comments has checked on [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
12+
13+
## [v1.0.0](https://github.com/ABGEO07/cherry-request/releases/tag/v1.0.0 "v1.0.0") (2019-02-25)
414
#### The first stable version
515

616
- Package available on: `composer require cherry-project/request`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require_once __DIR__ . '/vendor/autoload.php';
2020
## Class Request
2121
Import class
2222
```php
23-
use Cherry\Request;
23+
use Cherry\HttpUtils\Request;
2424
```
2525
Crete class new object
2626
```php

examples/test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//Include autoloader
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
use Cherry\Request;
6+
use Cherry\HttpUtils\Request;
77

88
$request = new Request();
99

src/Request.php renamed to src/HttpUtils/Request.php

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
<?php
2+
/**
3+
* The file contains Request class
4+
*
5+
* PHP version 5
6+
*
7+
* @category Library
8+
* @package Cherry
9+
* @author Temuri Takalandze <[email protected]>
10+
* @license https://github.com/ABGEO07/cherry-request/blob/master/LICENSE MIT
11+
* @link https://github.com/ABGEO07/cherry-request
12+
*/
213

3-
namespace Cherry;
14+
namespace Cherry\HttpUtils;
415

516
/**
617
* Cherry project request class
718
*
8-
* @package Cherry
9-
* @author Temuri Takalandze(ABGEO) <[email protected]>
19+
* @category Library
20+
* @package Cherry
21+
* @author Temuri Takalandze <[email protected]>
22+
* @license https://github.com/ABGEO07/cherry-request/blob/master/LICENSE MIT
23+
* @link https://github.com/ABGEO07/cherry-request
1024
*/
1125

1226
class Request
1327
{
1428
/**
1529
* Get request HTTP headers
1630
*
17-
* @param null|array|string $key
31+
* @param null|array|string $key Searched key or array of keys
32+
*
1833
* @return array|string
1934
*/
2035
public function getHeaders($key = null)
@@ -27,17 +42,21 @@ public function getHeaders($key = null)
2742
$value = isset($headers[$k]) ? $headers[$k] : null;
2843
$return[$k] = $value;
2944
}
30-
} else
45+
} else {
3146
$return = isset($headers[$key]) ? $headers[$key] : null;
32-
} else
47+
}
48+
} else {
3349
$return = $headers;
50+
}
51+
3452
return $return;
3553
}
3654

3755
/**
3856
* Check if request has header
3957
*
40-
* @param $key
58+
* @param string $key Http header for searching
59+
*
4160
* @return bool
4261
*/
4362
public function hasHeader($key)
@@ -72,7 +91,8 @@ public function getPath()
7291
*/
7392
function getScheme()
7493
{
75-
return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
94+
return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ?
95+
'https://' : 'http://';
7696
}
7797

7898
/**
@@ -95,14 +115,17 @@ function getQueryParams()
95115
/**
96116
* Get request query parameter by key
97117
*
98-
* @param $key
118+
* @param string $key Query parameter name
119+
*
99120
* @return string|null
100121
*/
101122
function getQuery($key)
102123
{
103124
$queryArray = $this->getQueryParams();
104-
if (isset($queryArray[$key]))
125+
if (isset($queryArray[$key])) {
105126
return $queryArray[$key];
127+
}
128+
106129
return null;
107130
}
108131

@@ -115,10 +138,12 @@ function getData()
115138
{
116139
$method = $this->getMethod();
117140
$return = null;
118-
if ($method == 'GET')
141+
if ($method == 'GET') {
119142
$return = $_GET;
120-
else if ($method == 'POST')
143+
} else if ($method == 'POST') {
121144
$return = $_POST;
145+
}
146+
122147
return $return;
123148
}
124149
}

0 commit comments

Comments
 (0)