Skip to content

Commit d3baed3

Browse files
committed
version 1.0.0
0 parents  commit d3baed3

File tree

9 files changed

+632
-0
lines changed

9 files changed

+632
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor/
2+
composer.lock
3+
phpcs.xml
4+
phpunit.xml

LICENSE

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

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[![Latest Stable Version](https://img.shields.io/packagist/v/webclient/ext-cache.svg?style=flat-square)](https://packagist.org/packages/webclient/ext-cache)
2+
[![Total Downloads](https://img.shields.io/packagist/dt/webclient/ext-cache.svg?style=flat-square)](https://packagist.org/packages/webclient/ext-cache/stats)
3+
[![License](https://img.shields.io/packagist/l/webclient/ext-cache.svg?style=flat-square)](https://github.com/phpwebclient/ext-cache/blob/master/LICENSE)
4+
[![PHP](https://img.shields.io/packagist/php-v/webclient/ext-cache.svg?style=flat-square)](https://php.net)
5+
6+
# webclient/ext-cache
7+
8+
Cache extension for PSR-18 HTTP client.
9+
10+
# Install
11+
12+
Install this package and your favorite [psr-18 implementation](https://packagist.org/providers/psr/http-client-implementation), [psr-17 implementation](https://packagist.org/providers/psr/http-factory-implementation) and [psr-6 implementation](https://packagist.org/providers/psr/simple-cache-implementation).
13+
14+
```bash
15+
composer require webclient/ext-cache:^1.0
16+
```
17+
18+
# Using
19+
20+
```php
21+
<?php
22+
23+
use Psr\Http\Client\ClientInterface;
24+
use Psr\Http\Message\RequestInterface;
25+
use Psr\Http\Message\ResponseFactoryInterface;
26+
use Psr\Http\Message\StreamFactoryInterface;
27+
use Psr\SimpleCache\CacheInterface;
28+
use Webclient\Extension\Cache\Client;
29+
30+
/**
31+
* @var ClientInterface $client Your PSR-18 HTTP Client
32+
* @var CacheInterface $cache Your PSR-6 Simple cache
33+
* @var ResponseFactoryInterface $responseFactory Your PSR-17 response factory
34+
* @var StreamFactoryInterface $streamFactory Your PSR-17 stream factory
35+
*/
36+
$http = new Client($client, $cache, $responseFactory, $streamFactory, 'unique-string-for-private-caching');
37+
38+
/** @var RequestInterface $request */
39+
$response = $http->sendRequest($request);
40+
```

composer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "webclient/ext-cache",
3+
"type": "library",
4+
"description": "Cache extension for PSR-18 HTTP client",
5+
"keywords": ["http", "client", "http-client", "http-client-extension", "cache"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Ivan Dudarev",
10+
"email": "[email protected]",
11+
"homepage": "https://ddrv.ru"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.0",
16+
"ext-json": "*",
17+
"ext-mbstring": "*",
18+
"psr/http-client": "^1.0",
19+
"psr/simple-cache": "^1.0",
20+
"psr/http-factory": "^1.0"
21+
},
22+
"require-dev": {
23+
"cache/array-adapter": "^1.0",
24+
"nyholm/psr7": "^1.3",
25+
"phpunit/phpunit": "^6.5",
26+
"squizlabs/php_codesniffer": "^3.5",
27+
"webclient/fake-http-client": "^1.0"
28+
},
29+
"provide": {
30+
"psr/http-client-implementation": "1.0"
31+
},
32+
"suggest": {
33+
"psr/http-client-implementation": "Choice your favorite psr-18 implementation",
34+
"psr/simple-cache-implementation": "Choice your favorite psr-6 implementation"
35+
},
36+
"autoload": {
37+
"psr-4": {
38+
"Webclient\\Extension\\Cache\\": "src/"
39+
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"Stuff\\Webclient\\Extension\\Cache\\": "stuff/",
44+
"Tests\\Webclient\\Extension\\Cache\\": "tests/"
45+
}
46+
}
47+
}

phpcs.xml.dist

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Coding standard">
3+
<description>Coding standard</description>
4+
5+
<!-- display progress -->
6+
<arg value="p"/>
7+
<!-- use colors in output -->
8+
<arg name="colors"/>
9+
10+
<!-- inherit rules from: -->
11+
<rule ref="PSR12">
12+
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
13+
</rule>
14+
15+
<!-- Paths to check -->
16+
<file>src</file>
17+
<file>stuff</file>
18+
<file>tests</file>
19+
</ruleset>

phpunit.xml.dist

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php" colors="true">
3+
<testsuites>
4+
<testsuite name="all">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

0 commit comments

Comments
 (0)