Skip to content

Commit 7346ec7

Browse files
committed
Synchronized package files with skeleton template
1 parent 41cc2d2 commit 7346ec7

File tree

6 files changed

+75
-63
lines changed

6 files changed

+75
-63
lines changed

.github/skeleton.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"package.name": "Polymorphine/Headers",
3+
"repository.name": "polymorphine/headers",
4+
"package.description": "HTTP Response headers middleware",
5+
"namespace.src": "Polymorphine\\Headers",
6+
"author.name": "Shudd3r",
7+
"author.email": "q3.shudder@gmail.com"
8+
}

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ jobs:
5050
- name: "Coding standard CodeSniffer checks"
5151
run: |
5252
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml src
53-
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/CodeSamples/* tests
53+
vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/code-samples/* tests
54+
- name: "Package skeleton validation"
55+
run: vendor/bin/polymorphine-skeleton check
5456
- name: "Run PhpUnit tests with coverage"
5557
run: |
5658
mkdir -p build/logs

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.idea/
2-
vendor/
3-
build/
4-
temp/
1+
/.dev/
2+
/vendor/
53
/composer.lock

README.md

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,63 @@
11
# Polymorphine/Headers
2-
[![Latest Stable Version](https://poser.pugx.org/polymorphine/headers/version)](https://packagist.org/packages/polymorphine/headers)
2+
[![Latest stable release](https://poser.pugx.org/polymorphine/headers/version)](https://packagist.org/packages/polymorphine/headers)
33
[![Build status](https://github.com/polymorphine/headers/workflows/build/badge.svg)](https://github.com/polymorphine/headers/actions)
44
[![Coverage status](https://coveralls.io/repos/github/polymorphine/headers/badge.svg?branch=develop)](https://coveralls.io/github/polymorphine/headers?branch=develop)
55
[![PHP version](https://img.shields.io/packagist/php-v/polymorphine/headers.svg)](https://packagist.org/packages/polymorphine/headers)
66
[![LICENSE](https://img.shields.io/github/license/polymorphine/headers.svg?color=blue)](LICENSE)
77
### HTTP Response headers middleware
88

99
### Installation with [Composer](https://getcomposer.org/)
10-
php composer.phar require polymorphine/headers
10+
```bash
11+
composer require polymorphine/headers
12+
```
1113

1214
### Basic usage
13-
##### *Set-Cookie header*
1415

16+
##### *Set-Cookie header*
1517
1. Instantiate a cookie builder using `ResponseHeaders` context:
16-
17-
$headers = new ResponseHeaders();
18-
$cookieSetup = new CookieSetup($headers);
19-
18+
```php
19+
$headers = new ResponseHeaders();
20+
$cookieSetup = new CookieSetup($headers);
21+
```
2022
Alternatively, instantiating `CookieSetup` is possible with `ResponseHeaders` method:
21-
22-
$cookieSetup = $context->cookieSetup();
23-
23+
```php
24+
$cookieSetup = $context->cookieSetup();
25+
```
2426
2. Configure cookie with array of its directives/attributes
25-
(see [`CookieSetup::directives()`](/src/Cookie/CookieSetup.php#L48) method):
26-
27-
$cookieSetup->directives([
28-
'Domain' => 'example.com',
29-
'Path' => '/admin',
30-
'Expires' => new DateTime(...),
31-
'MaxAge' => 1234,
32-
'Secure' => true,
33-
'HttpOnly' => true,
34-
'SameSite' => 'Strict'
35-
]);
36-
27+
(see [`CookieSetup::directives()`](/src/Cookie/CookieSetup.php#L51) method):
28+
```php
29+
$cookieSetup->directives([
30+
'Domain' => 'example.com',
31+
'Path' => '/admin',
32+
'Expires' => new DateTime(...),
33+
'MaxAge' => 1234,
34+
'Secure' => true,
35+
'HttpOnly' => true,
36+
'SameSite' => 'Strict'
37+
]);
38+
```
3739
Modifying setup object is also possible with its builder methods:
38-
39-
$cookieSetup->domain('example.com')
40-
->path('/admin')
41-
->expires(new DateTime(...))
42-
->maxAge(1234)
43-
->secure()
44-
->httpOnly()
45-
->sameSite('Strict');
46-
40+
```php
41+
$cookieSetup->domain('example.com')
42+
->path('/admin')
43+
->expires(new DateTime(...))
44+
->maxAge(1234)
45+
->secure()
46+
->httpOnly()
47+
->sameSite('Strict');
48+
```
4749
3. Instantiate [`Cookie`](/src/Cookie.php) type object with its name:
48-
49-
$cookie = $cookieSetup->cookie('MyCookie');
50-
50+
```php
51+
$cookie = $cookieSetup->cookie('MyCookie');
52+
```
5153
4. Send value:
52-
53-
$cookie->send('value');
54-
54+
```php
55+
$cookie->send('value');
56+
```
5557
or order to revoke cookie, so that it should not be sent with future requests:
56-
57-
$cookie->revoke();
58-
58+
```php
59+
$cookie->revoke();
60+
```
5961
Each cookie can send/revoke header only once
6062

6163
##### Directives and Attributes
@@ -67,15 +69,15 @@ Concise description with additional class logic is explained in docBlocks of mut
6769
of [`CookieSetup`](src/Cookie/CookieSetup.php) class.
6870

6971
Here are some class-specific rules for setting those directives:
70-
* Empty values and root path (`/`) might be omitted as they're same as default.
71-
* `SameSite` allowed values are `Strict` or `Lax`, but `Lax` will be set for any non-empty value given.
72-
* `Expires` and `MaxAge` are different ways to set the same cookie's expiry date.
72+
- Empty values and root path (`/`) might be omitted as they're same as default.
73+
- `SameSite` allowed values are `Strict` or `Lax`, but `Lax` will be set for any non-empty value given.
74+
- `Expires` and `MaxAge` are different ways to set the same cookie's expiry date.
7375
If both directives will be passed into constructor or `directivesArray()` method,
7476
last value will be used due to overwrite.
7577

7678
##### Cookie with predefined directives
7779

7880
`CookieSetup` has two alternative methods creating `Cookie` instance: `CookieSetup::permanentCookie()` and
7981
`CookieSetup::sessionCookie()`.
80-
* *Permanent* constructor sets long (5 years) expiry values (`Expires` and `MaxAge`)
81-
* *Session* constructor sets security directives (`HttpOnly` and `SameSite=Lax`)
82+
- *Permanent* constructor sets long (5 years) expiry values (`Expires` and `MaxAge`)
83+
- *Session* constructor sets security directives (`HttpOnly` and `SameSite=Lax`)

composer.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
"name": "polymorphine/headers",
33
"description": "HTTP Response headers middleware",
44
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Shudd3r",
9+
"email": "q3.shudder@gmail.com"
10+
}
11+
],
512
"minimum-stability": "stable",
613
"require": {
714
"php": "^7.4 || ^8.0",
@@ -10,15 +17,8 @@
1017
"psr/http-server-middleware": "^1.0"
1118
},
1219
"require-dev": {
13-
"polymorphine/dev": "0.1.*"
20+
"polymorphine/dev": "0.2.*"
1421
},
15-
"license": "MIT",
16-
"authors": [
17-
{
18-
"name": "Shudd3r",
19-
"email": "q3.shudder@gmail.com"
20-
}
21-
],
2222
"autoload": {
2323
"psr-4": {
2424
"Polymorphine\\Headers\\": "src/"
@@ -31,9 +31,11 @@
3131
},
3232
"scripts": {
3333
"test-cs": [
34-
"vendor/bin/php-cs-fixer --dry-run -v --config=cs-fixer.php.dist --path-mode=intersection fix src tests",
35-
"vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml src",
36-
"vendor/bin/phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/CodeSamples/* tests"
37-
]
34+
"php-cs-fixer --dry-run -v --config=cs-fixer.php.dist --path-mode=intersection fix src tests",
35+
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml src",
36+
"phpcs --extensions=php --standard=vendor/polymorphine/dev/phpcs.xml --ignore=*/code-samples/* tests"
37+
],
38+
"test-php": "phpunit",
39+
"test-skeleton": "polymorphine-skeleton check"
3840
}
3941
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
cacheResultFile="temp/.phpunit.result.cache"
5+
cacheResultFile=".dev/temp/.phpunit.result.cache"
66
colors="true"
77
bootstrap="vendor/autoload.php"
88
>

0 commit comments

Comments
 (0)