Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies, switch to github actions #19

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PHPUnit

on:
pull_request:
push:
branches: [ master ]

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php:
- '7.2'
- '8.3'
symfony:
- '5.0.*'
- '5.4.*' # LTS
- '6.0.*'
- '7.0.*'
exclude:
- php: '7.2'
symfony: '6.0.*' # requires PHP >=8.1
- php: '7.2'
symfony: '7.0.*' # requires PHP >=8.2

runs-on: ${{ matrix.os }}

env:
SYMFONY: ${{ matrix.symfony }}

steps:
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: date.timezone='UTC'
tools: composer:v2

- name: Require symfony
run: composer --no-update require symfony/symfony:"${SYMFONY}"

- name: Install dependencies
run: |
composer update
vendor/bin/simple-phpunit install

- name: Test
run: |
composer validate --strict --no-check-lock
vendor/bin/simple-phpunit --coverage-text --verbose
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients.

## Requirements
- PHP 7.0 or above
- PHP 7.2 or above
- [Guzzle Bundle][1]
- [Guzzle Cache middleware][2]

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
],

"require": {
"php": "^7.0 || ^8.0",
"guzzlehttp/guzzle": "~6.0 || ^7.5.0",
"php": ">=7.2",
"guzzlehttp/guzzle": "^6.5.8|^7.4.5",
"eightpoints/guzzle-bundle": "~8.0",
"symfony/http-kernel": "~4.0 || ~5.0|| ~6.0",
"symfony/config": "~4.0 || ~5.0|| ~6.0",
"symfony/dependency-injection": "~4.0 || ~5.0|| ~6.0",
"symfony/expression-language": "~4.0 || ~5.0|| ~6.0",
"kevinrob/guzzle-cache-middleware": "~4.0"
"symfony/http-kernel": "~5.0|~6.0|~7.0",
"symfony/config": "~5.0|~6.0|~7.0",
"symfony/dependency-injection": "~5.0|~6.0|~7.0",
"symfony/expression-language": "~5.0|~6.0|~7.0",
"kevinrob/guzzle-cache-middleware": "~4.0|~5.0"
},

"require-dev": {
"symfony/phpunit-bridge": "~4.0|~5.0",
"symfony/phpunit-bridge": "~5.0|~6.0|~7.0",
"php-coveralls/php-coveralls": "~2.2"
},

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
>
<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
</php>

<testsuites>
Expand Down
6 changes: 1 addition & 5 deletions src/DependencyInjection/GuzzleCacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

class GuzzleCacheExtension extends Extension
{
/**
* @param array $configs
* @param ContainerBuilder $container
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));

Expand Down
171 changes: 51 additions & 120 deletions src/Event/InvalidateRequestEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,140 +3,71 @@
namespace Gregurco\Bundle\GuzzleBundleCachePlugin\Event;

use Psr\Http\Message\UriInterface;
use Symfony\Component\EventDispatcher\Event as BaseEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\Event as ContractsBaseEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\Event;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;

if (is_subclass_of(EventDispatcher::class, EventDispatcherInterface::class)) {
class InvalidateRequestEvent extends ContractsBaseEvent
{
/** @var Client */
protected $client;

/** @var string */
protected $method;

/** @var string */
protected $uri;

/**
* @param Client $client
* @param string $method
* @param string $uri
*/
public function __construct(Client $client, string $method, string $uri)
{
$this->client = $client;
$this->method = $method;
$this->uri = $uri;
}

/**
* @return Client
*/
public function getClient(): Client
{
return $this->client;
}
class InvalidateRequestEvent extends Event
{
/** @var Client */
protected $client;

/**
* @return string
*/
public function getMethod(): string
{
return $this->method;
}

/**
* @return string
*/
public function getUri(): string
{
return $this->uri;
}

/**
* @return Request
*/
public function getRequest(): Request
{
$baseUri = $this->client->getConfig('base_uri');
/** @var string */
protected $method;

if ($baseUri instanceof UriInterface) {
$uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri));
} else {
$uri = $this->uri;
}
/** @var string */
protected $uri;

return new Request($this->method, $uri);
}
}
} else {
class InvalidateRequestEvent extends BaseEvent
/**
* @param Client $client
* @param string $method
* @param string $uri
*/
public function __construct(Client $client, string $method, string $uri)
{
/** @var Client */
protected $client;

/** @var string */
protected $method;
$this->client = $client;
$this->method = $method;
$this->uri = $uri;
}

/** @var string */
protected $uri;
/**
* @return Client
*/
public function getClient(): Client
{
return $this->client;
}

/**
* @param Client $client
* @param string $method
* @param string $uri
*/
public function __construct(Client $client, string $method, string $uri)
{
$this->client = $client;
$this->method = $method;
$this->uri = $uri;
}
/**
* @return string
*/
public function getMethod(): string
{
return $this->method;
}

/**
* @return Client
*/
public function getClient(): Client
{
return $this->client;
}
/**
* @return string
*/
public function getUri(): string
{
return $this->uri;
}

/**
* @return string
*/
public function getMethod(): string
{
return $this->method;
}
/**
* @return Request
*/
public function getRequest(): Request
{
$baseUri = $this->client->getConfig('base_uri');

/**
* @return string
*/
public function getUri(): string
{
return $this->uri;
if ($baseUri instanceof UriInterface) {
$uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri));
} else {
$uri = $this->uri;
}

/**
* @return Request
*/
public function getRequest(): Request
{
$baseUri = $this->client->getConfig('base_uri');

if ($baseUri instanceof UriInterface) {
$uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri));
} else {
$uri = $this->uri;
}

return new Request($this->method, $uri);
}
return new Request($this->method, $uri);
}
}
1 change: 0 additions & 1 deletion src/EventListener/InvalidateRequestSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ protected function getClientIdentifier(Client $client): string
{
return spl_object_hash($client);
}

}