Skip to content

Commit

Permalink
Release 4.0.0 (#29)
Browse files Browse the repository at this point in the history
Massive changes that implement many PSR standards, and now only supports PHP7.3+, and Symfony 4 and 5.
  • Loading branch information
wtfzdotnet authored Jan 4, 2021
1 parent bf05572 commit 765876f
Show file tree
Hide file tree
Showing 30 changed files with 2,565 additions and 355 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.editorconfig export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.php_cs export-ignore
phpstan.neon.dist export-ignore
Tests export-ignore
45 changes: 45 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Coding Standards"

on: ["pull_request"]

jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 10

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"

- name: "Cache dependencies installed with Composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies with Composer"
run: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable"

- name: "Install git-phpcs"
run: "wget https://github.com/diff-sniffer/git/releases/download/0.3.2/git-phpcs.phar"

- name: "Fetch head branch"
run: "git remote set-branches --add origin $GITHUB_BASE_REF && git fetch origin $GITHUB_BASE_REF"

- name: "Run git-phpcs"
run: "php git-phpcs.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr"
89 changes: 89 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "Continuous Integration"

on: ["pull_request", "push"]

env:
fail-fast: true

jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}
SYMFONY_DEPRECATIONS_HELPER: ${{matrix.symfony-deprecations-helper}}

strategy:
matrix:
php-version:
- "7.3"
- "7.4"
deps:
- "normal"
symfony-require:
- ""
symfony-deprecations-helper:
- ""
include:
# Test against latest Symfony 4.3 stable
- symfony-require: "4.3.*"
php-version: "7.3"
deps: "normal"

# Test against latest Symfony 4.4 dev
- symfony-require: "4.4.*"
php-version: "7.3"
deps: "dev"

# Test against latest Symfony 5.2 dev
- symfony-require: "5.2.*"
php-version: "7.3"
deps: "dev"

- php-version: "8.0"
deps: "dev"
symfony-deprecations-helper: "weak"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP with PCOV"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install stable dependencies with composer"
run: "composer update --no-interaction --prefer-dist --prefer-stable"
if: "${{ matrix.deps == 'normal' }}"

- name: "Install dev dependencies with composer"
run: "composer update --no-interaction --prefer-dist"
if: "${{ matrix.deps == 'dev' }}"

- name: "Install lowest possible dependencies with composer"
run: "composer update --no-interaction --prefer-dist --prefer-stable --prefer-lowest"
if: "${{ matrix.deps == 'low' }}"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-${{ matrix.php-version }}-${{ matrix.deps }}-${{ hashFiles('composer.lock') }}.coverage"
path: "coverage.xml"

- uses: codecov/codecov-action@v1
with:
verbose: true
56 changes: 56 additions & 0 deletions .github/workflows/static-analysis.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Static Analysis

on:
pull_request:

jobs:
static-analysis-phpstan:
name: "PHPStan"
runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: cs2pr

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run PHPStan"
run: "vendor/bin/phpstan analyse --error-format=checkstyle --no-progress -c phpstan.neon | cs2pr"

static-analysis-psalm:
name: "Psalm"
runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
composer.lock
.idea/
vendor/

coverage/
phpcs.cache
.phpunit.result.cache
.phpcs-cache
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

54 changes: 37 additions & 17 deletions ClientConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
<?php

namespace Tmdb\SymfonyBundle;

use Doctrine\Common\Cache\Cache;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Tmdb\ConfigurationInterface;
use Tmdb\Token\Api\ApiToken;

class ClientConfiguration extends ParameterBag implements ConfigurationInterface {
/**
* Class ClientConfiguration
* @package Tmdb\SymfonyBundle
*/
class ClientConfiguration extends ParameterBag implements ConfigurationInterface
{
/**
* ClientConfiguration constructor.
* @param ApiToken $apiToken
* @param EventDispatcherInterface $eventDispatcher
* @param ClientInterface $client
* @param RequestFactoryInterface $requestFactory
* @param ResponseFactoryInterface $responseFactory
* @param StreamFactoryInterface $streamFactory
* @param UriFactoryInterface $uriFactory
* @param array $options
*/
public function __construct(
ApiToken $apiToken,
EventDispatcherInterface $eventDispatcher,
ClientInterface $client,
RequestFactoryInterface $requestFactory,
ResponseFactoryInterface $responseFactory,
StreamFactoryInterface $streamFactory,
UriFactoryInterface $uriFactory,
array $options = []
){
$this->parameters = $options;

$this->parameters['event_dispatcher'] = $eventDispatcher;
}
) {
$options['api_token'] = $apiToken;
$options['event_dispatcher']['adapter'] = $eventDispatcher;
$options['http']['client'] = $client;
$options['http']['request_factory'] = $requestFactory;
$options['http']['response_factory'] = $responseFactory;
$options['http']['stream_factory'] = $streamFactory;
$options['http']['uri_factory'] = $uriFactory;

public function setCacheHandler(Cache $handler = null)
{
$this->parameters['cache']['handler'] = $handler;
}
// Library handles it as an api_token
unset($options['bearer_token']);

/**
* @return array
*/
public function all()
{
return $this->parameters;
parent::__construct($options);
}
}
Loading

0 comments on commit 765876f

Please sign in to comment.