Skip to content

Commit 765876f

Browse files
authored
Release 4.0.0 (#29)
Massive changes that implement many PSR standards, and now only supports PHP7.3+, and Symfony 4 and 5.
1 parent bf05572 commit 765876f

30 files changed

+2565
-355
lines changed

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.editorconfig export-ignore
2+
.gitattributes export-ignore
3+
.github export-ignore
4+
.gitignore export-ignore
5+
.php_cs export-ignore
6+
phpstan.neon.dist export-ignore
7+
Tests export-ignore
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Coding Standards"
2+
3+
on: ["pull_request"]
4+
5+
jobs:
6+
coding-standards:
7+
name: "Coding Standards"
8+
runs-on: "ubuntu-20.04"
9+
10+
strategy:
11+
matrix:
12+
php-version:
13+
- "7.4"
14+
15+
steps:
16+
- name: "Checkout"
17+
uses: "actions/checkout@v2"
18+
with:
19+
fetch-depth: 10
20+
21+
- name: "Install PHP"
22+
uses: "shivammathur/setup-php@v2"
23+
with:
24+
coverage: "none"
25+
php-version: "${{ matrix.php-version }}"
26+
tools: "cs2pr"
27+
28+
- name: "Cache dependencies installed with Composer"
29+
uses: "actions/cache@v2"
30+
with:
31+
path: "~/.composer/cache"
32+
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
33+
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
34+
35+
- name: "Install dependencies with Composer"
36+
run: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable"
37+
38+
- name: "Install git-phpcs"
39+
run: "wget https://github.com/diff-sniffer/git/releases/download/0.3.2/git-phpcs.phar"
40+
41+
- name: "Fetch head branch"
42+
run: "git remote set-branches --add origin $GITHUB_BASE_REF && git fetch origin $GITHUB_BASE_REF"
43+
44+
- name: "Run git-phpcs"
45+
run: "php git-phpcs.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: "Continuous Integration"
2+
3+
on: ["pull_request", "push"]
4+
5+
env:
6+
fail-fast: true
7+
8+
jobs:
9+
phpunit:
10+
name: "PHPUnit"
11+
runs-on: "ubuntu-20.04"
12+
env:
13+
SYMFONY_REQUIRE: ${{matrix.symfony-require}}
14+
SYMFONY_DEPRECATIONS_HELPER: ${{matrix.symfony-deprecations-helper}}
15+
16+
strategy:
17+
matrix:
18+
php-version:
19+
- "7.3"
20+
- "7.4"
21+
deps:
22+
- "normal"
23+
symfony-require:
24+
- ""
25+
symfony-deprecations-helper:
26+
- ""
27+
include:
28+
# Test against latest Symfony 4.3 stable
29+
- symfony-require: "4.3.*"
30+
php-version: "7.3"
31+
deps: "normal"
32+
33+
# Test against latest Symfony 4.4 dev
34+
- symfony-require: "4.4.*"
35+
php-version: "7.3"
36+
deps: "dev"
37+
38+
# Test against latest Symfony 5.2 dev
39+
- symfony-require: "5.2.*"
40+
php-version: "7.3"
41+
deps: "dev"
42+
43+
- php-version: "8.0"
44+
deps: "dev"
45+
symfony-deprecations-helper: "weak"
46+
47+
steps:
48+
- name: "Checkout"
49+
uses: "actions/checkout@v2"
50+
with:
51+
fetch-depth: 2
52+
53+
- name: "Install PHP with PCOV"
54+
uses: "shivammathur/setup-php@v2"
55+
with:
56+
php-version: "${{ matrix.php-version }}"
57+
coverage: "pcov"
58+
59+
- name: "Cache dependencies installed with composer"
60+
uses: "actions/cache@v2"
61+
with:
62+
path: "~/.composer/cache"
63+
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
64+
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
65+
66+
- name: "Install stable dependencies with composer"
67+
run: "composer update --no-interaction --prefer-dist --prefer-stable"
68+
if: "${{ matrix.deps == 'normal' }}"
69+
70+
- name: "Install dev dependencies with composer"
71+
run: "composer update --no-interaction --prefer-dist"
72+
if: "${{ matrix.deps == 'dev' }}"
73+
74+
- name: "Install lowest possible dependencies with composer"
75+
run: "composer update --no-interaction --prefer-dist --prefer-stable --prefer-lowest"
76+
if: "${{ matrix.deps == 'low' }}"
77+
78+
- name: "Run PHPUnit"
79+
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
80+
81+
- name: "Upload coverage file"
82+
uses: "actions/upload-artifact@v2"
83+
with:
84+
name: "phpunit-${{ matrix.php-version }}-${{ matrix.deps }}-${{ hashFiles('composer.lock') }}.coverage"
85+
path: "coverage.xml"
86+
87+
- uses: codecov/codecov-action@v1
88+
with:
89+
verbose: true
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Static Analysis
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
static-analysis-phpstan:
8+
name: "PHPStan"
9+
runs-on: "ubuntu-latest"
10+
11+
strategy:
12+
matrix:
13+
php-version:
14+
- "7.4"
15+
16+
steps:
17+
- name: "Checkout code"
18+
uses: "actions/checkout@v2"
19+
20+
- name: "Install PHP"
21+
uses: "shivammathur/setup-php@v2"
22+
with:
23+
coverage: "none"
24+
php-version: "${{ matrix.php-version }}"
25+
tools: cs2pr
26+
27+
- name: "Install dependencies with Composer"
28+
uses: "ramsey/composer-install@v1"
29+
30+
- name: "Run PHPStan"
31+
run: "vendor/bin/phpstan analyse --error-format=checkstyle --no-progress -c phpstan.neon | cs2pr"
32+
33+
static-analysis-psalm:
34+
name: "Psalm"
35+
runs-on: "ubuntu-latest"
36+
37+
strategy:
38+
matrix:
39+
php-version:
40+
- "7.4"
41+
42+
steps:
43+
- name: "Checkout code"
44+
uses: "actions/checkout@v2"
45+
46+
- name: "Install PHP"
47+
uses: "shivammathur/setup-php@v2"
48+
with:
49+
coverage: "none"
50+
php-version: "${{ matrix.php-version }}"
51+
52+
- name: "Install dependencies with Composer"
53+
uses: "ramsey/composer-install@v1"
54+
55+
- name: "Run a static analysis with vimeo/psalm"
56+
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
composer.lock
22
.idea/
33
vendor/
4-
4+
coverage/
5+
phpcs.cache
6+
.phpunit.result.cache
7+
.phpcs-cache

.travis.yml

-37
This file was deleted.

ClientConfiguration.php

+37-17
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,55 @@
11
<?php
2+
23
namespace Tmdb\SymfonyBundle;
34

4-
use Doctrine\Common\Cache\Cache;
5+
use Psr\Http\Client\ClientInterface;
6+
use Psr\Http\Message\RequestFactoryInterface;
7+
use Psr\Http\Message\ResponseFactoryInterface;
8+
use Psr\Http\Message\StreamFactoryInterface;
9+
use Psr\Http\Message\UriFactoryInterface;
510
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
611
use Symfony\Component\HttpFoundation\ParameterBag;
712
use Tmdb\ConfigurationInterface;
13+
use Tmdb\Token\Api\ApiToken;
814

9-
class ClientConfiguration extends ParameterBag implements ConfigurationInterface {
15+
/**
16+
* Class ClientConfiguration
17+
* @package Tmdb\SymfonyBundle
18+
*/
19+
class ClientConfiguration extends ParameterBag implements ConfigurationInterface
20+
{
1021
/**
22+
* ClientConfiguration constructor.
23+
* @param ApiToken $apiToken
1124
* @param EventDispatcherInterface $eventDispatcher
25+
* @param ClientInterface $client
26+
* @param RequestFactoryInterface $requestFactory
27+
* @param ResponseFactoryInterface $responseFactory
28+
* @param StreamFactoryInterface $streamFactory
29+
* @param UriFactoryInterface $uriFactory
1230
* @param array $options
1331
*/
1432
public function __construct(
33+
ApiToken $apiToken,
1534
EventDispatcherInterface $eventDispatcher,
35+
ClientInterface $client,
36+
RequestFactoryInterface $requestFactory,
37+
ResponseFactoryInterface $responseFactory,
38+
StreamFactoryInterface $streamFactory,
39+
UriFactoryInterface $uriFactory,
1640
array $options = []
17-
){
18-
$this->parameters = $options;
19-
20-
$this->parameters['event_dispatcher'] = $eventDispatcher;
21-
}
41+
) {
42+
$options['api_token'] = $apiToken;
43+
$options['event_dispatcher']['adapter'] = $eventDispatcher;
44+
$options['http']['client'] = $client;
45+
$options['http']['request_factory'] = $requestFactory;
46+
$options['http']['response_factory'] = $responseFactory;
47+
$options['http']['stream_factory'] = $streamFactory;
48+
$options['http']['uri_factory'] = $uriFactory;
2249

23-
public function setCacheHandler(Cache $handler = null)
24-
{
25-
$this->parameters['cache']['handler'] = $handler;
26-
}
50+
// Library handles it as an api_token
51+
unset($options['bearer_token']);
2752

28-
/**
29-
* @return array
30-
*/
31-
public function all()
32-
{
33-
return $this->parameters;
53+
parent::__construct($options);
3454
}
3555
}

0 commit comments

Comments
 (0)