Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit a1f0c81

Browse files
committed
First commit
Improved speed now stable
0 parents  commit a1f0c81

14 files changed

+980
-0
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Windows image file caches
2+
Thumbs.db
3+
ehthumbs.db
4+
5+
# Folder config file
6+
Desktop.ini
7+
8+
# Recycle Bin used on file shares
9+
$RECYCLE.BIN/
10+
11+
# Windows Installer files
12+
*.cab
13+
*.msi
14+
*.msm
15+
*.msp
16+
17+
# Windows shortcuts
18+
*.lnk
19+
20+
# =========================
21+
# Operating System Files
22+
# =========================
23+
24+
# OSX
25+
# =========================
26+
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Thumbnails
32+
._*
33+
34+
# Files that might appear on external disk
35+
.Spotlight-V100
36+
.Trashes
37+
38+
# Directories potentially created on remote AFP share
39+
.AppleDB
40+
.AppleDesktop
41+
Network Trash Folder
42+
Temporary Items
43+
.apdisk

.scrutinizer.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
filter:
2+
excluded_paths: [tests/*]
3+
checks:
4+
php:
5+
code_rating: true
6+
remove_extra_empty_lines: true
7+
remove_php_closing_tag: true
8+
remove_trailing_whitespace: true
9+
fix_use_statements:
10+
remove_unused: true
11+
preserve_multiple: false
12+
preserve_blanklines: true
13+
order_alphabetically: true
14+
fix_php_opening_tag: true
15+
fix_linefeed: true
16+
fix_line_ending: true
17+
fix_identation_4spaces: true
18+
fix_doc_comments: true
19+
tools:
20+
external_code_coverage: true
21+
php_analyzer: true
22+
php_code_coverage: false
23+
php_code_sniffer:
24+
config:
25+
standard: PSR4
26+
filter:
27+
paths: ['src']
28+
php_loc:
29+
enabled: true
30+
excluded_dirs: [vendor, tests]
31+
php_cpd:
32+
enabled: true
33+
excluded_dirs: [vendor, tests]

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
matrix:
10+
allow_failures:
11+
- php: hhvm
12+
13+
before_script:
14+
- travis_retry composer self-update
15+
- travis_retry composer install --no-interaction --prefer-source --dev
16+
17+
script:
18+
- phpunit --coverage-text --coverage-clover=coverage.clover
19+
20+
after_script:
21+
- php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Aurora
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Aurora.Http
2+
3+
## License
4+
5+
MIT LICENSE
6+
Permission is hereby granted, free of charge, to any person obtaining
7+
a copy of this software and associated documentation files (the
8+
"Software"), to deal in the Software without restriction, including
9+
without limitation the rights to use, copy, modify, merge, publish,
10+
distribute, sublicense, and/or sell copies of the Software, and to
11+
permit persons to whom the Software is furnished to do so, subject to
12+
the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "aurora-framework/http",
3+
"description": "This is a simple and easy abstraction over top an HTTP response.",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "VeeeneX",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"require": {
12+
"php": ">=5.4.0"
13+
},
14+
"autoload": {
15+
"psr-4": {
16+
"Aurora\\": "src"
17+
}
18+
}
19+
}

src/Http/Cookie.php

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?php
2+
3+
/**
4+
* Aurora - Framework
5+
*
6+
* Aurora is fast, simple, extensible Framework
7+
*
8+
* @category Framework
9+
* @package Aurora
10+
* @author VeeeneX <[email protected]>
11+
* @copyright 2015 Caroon
12+
* @license MIT
13+
* @version 0.1.2
14+
* @link http://caroon.com/Aurora
15+
*
16+
*/
17+
18+
namespace Aurora\Http;
19+
20+
class Cookie implements CookieInterface
21+
{
22+
private $name;
23+
private $value;
24+
private $domain;
25+
private $path;
26+
private $maxAge;
27+
private $secure;
28+
private $httpOnly;
29+
30+
public function __construct($name, $value)
31+
{
32+
$this->name = (string) $name;
33+
$this->value = (string) $value;
34+
}
35+
36+
/**
37+
* Returns the cookie name.
38+
*
39+
* @return string
40+
*/
41+
public function getName()
42+
{
43+
return $this->name;
44+
}
45+
46+
/**
47+
* Sets the cookie value.
48+
*
49+
* @param string $value
50+
* @return void
51+
*/
52+
public function setValue($value)
53+
{
54+
$this->value = (string) $value;
55+
}
56+
57+
/**
58+
* Sets the cookie max age in seconds.
59+
*
60+
* @param integer $seconds
61+
* @return void
62+
*/
63+
public function setMaxAge($seconds)
64+
{
65+
$this->maxAge = (int) $seconds;
66+
}
67+
68+
/**
69+
* Sets the cookie domain.
70+
*
71+
* @param string $domain
72+
* @return void
73+
*/
74+
public function setDomain($domain)
75+
{
76+
$this->domain = (string) $domain;
77+
}
78+
79+
/**
80+
* Sets the cookie path.
81+
*
82+
* @param string $path
83+
* @return void
84+
*/
85+
public function setPath($path)
86+
{
87+
$this->path = (string) $path;
88+
}
89+
90+
/**
91+
* Sets the cookie secure flag.
92+
*
93+
* @param boolean $secure
94+
* @return void
95+
*/
96+
public function setSecure($secure)
97+
{
98+
$this->secure = (bool) $secure;
99+
}
100+
101+
/**
102+
* Sets the cookie httpOnly flag.
103+
*
104+
* @param boolean $httpOnly
105+
* @return void
106+
*/
107+
public function setHttpOnly($httpOnly)
108+
{
109+
$this->httpOnly = (bool) $httpOnly;
110+
}
111+
112+
/**
113+
* Returns the cookie HTTP header string.
114+
*
115+
* @return string
116+
*/
117+
public function getHeaderString()
118+
{
119+
$parts = [
120+
$this->name . '=' . rawurlencode($this->value),
121+
$this->getMaxAgeString(),
122+
$this->getExpiresString(),
123+
$this->getDomainString(),
124+
$this->getPathString(),
125+
$this->getSecureString(),
126+
$this->getHttpOnlyString(),
127+
];
128+
129+
$filteredParts = array_filter($parts);
130+
131+
return implode('; ', $filteredParts);
132+
}
133+
134+
private function getMaxAgeString()
135+
{
136+
if ($this->maxAge !== null) {
137+
return 'Max-Age='. $this->maxAge;
138+
}
139+
}
140+
141+
private function getExpiresString()
142+
{
143+
if ($this->maxAge !== null) {
144+
return 'expires=' . gmdate(
145+
"D, d-M-Y H:i:s",
146+
time() + $this->maxAge
147+
) . ' GMT';
148+
}
149+
}
150+
151+
private function getDomainString()
152+
{
153+
if ($this->domain) {
154+
return "domain=$this->domain";
155+
}
156+
}
157+
158+
private function getPathString()
159+
{
160+
if ($this->path) {
161+
return "path=$this->path";
162+
}
163+
}
164+
165+
private function getSecureString()
166+
{
167+
if ($this->secure) {
168+
return 'secure';
169+
}
170+
}
171+
172+
private function getHttpOnlyString()
173+
{
174+
if ($this->httpOnly) {
175+
return 'HttpOnly';
176+
}
177+
}
178+
}

0 commit comments

Comments
 (0)