diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f81b54..7d51cda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,7 @@ jobs: composer install --prefer-dist --no-interaction --no-progress --no-suggest --ignore-platform-reqs composer require --prefer-dist --no-interaction --no-progress --no-suggest --ignore-platform-reqs cakasim/payone-sdk-http-message:^0.1 composer require --prefer-dist --no-interaction --no-progress --no-suggest --ignore-platform-reqs cakasim/payone-sdk-stream-client:^0.1 + composer require --prefer-dist --no-interaction --no-progress --no-suggest --ignore-platform-reqs cakasim/payone-sdk-silent-logger:^0.1 - name: Run Coding Style Checks run: vendor/bin/phpcsf -v fix --dry-run --allow-risky=yes diff --git a/.travis.yml b/.travis.yml index eb1952e..266f810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ install: - composer install --prefer-dist --no-interaction --no-suggest --ignore-platform-reqs - composer require --prefer-dist --no-interaction --no-suggest --ignore-platform-reqs cakasim/payone-sdk-http-message:^0.1 - composer require --prefer-dist --no-interaction --no-suggest --ignore-platform-reqs cakasim/payone-sdk-stream-client:^0.1 + - composer require --prefer-dist --no-interaction --no-suggest --ignore-platform-reqs cakasim/payone-sdk-silent-logger:^0.1 before_script: - composer download-phpunit diff --git a/composer.json b/composer.json index 088b2ad..fcc18fc 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "require-dev": {}, "suggest": { "cakasim/payone-sdk-http-message": "Provides the default HTTP message implementation.", - "cakasim/payone-sdk-stream-client": "Provides the default HTTP client implementation." + "cakasim/payone-sdk-stream-client": "Provides the default HTTP client implementation.", + "cakasim/payone-sdk-silent-logger": "Provides the default logger implementation." }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 92a5b91..0000000 --- a/composer.lock +++ /dev/null @@ -1,267 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "ba3025be1e914bca26265bf9f65aaef4", - "packages": [ - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/http-client", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "496a823ef742b632934724bf769560c2a5c7c44e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e", - "reference": "496a823ef742b632934724bf769560c2a5c7c44e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "time": "2018-10-30T23:29:13+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "time": "2019-04-30T12:38:16+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "psr/log", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2019-11-01T11:05:21+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^7.1" - }, - "platform-dev": [] -} diff --git a/src/ContainerBuilder.php b/src/ContainerBuilder.php index f26cb31..0bf9b38 100644 --- a/src/ContainerBuilder.php +++ b/src/ContainerBuilder.php @@ -64,9 +64,6 @@ class ContainerBuilder // --- PSR Bindings --- - // PSR-3 - \Psr\Log\LoggerInterface::class => [\Cakasim\Payone\Sdk\Log\SilentLogger::class, true], - // PSR-7 // Concrete PSR-7 implementation is provided by PSR-17 // factory bindings below. @@ -113,6 +110,9 @@ class ContainerBuilder // PSR-18 bindings, from cakasim/payone-sdk-stream-client package \Psr\Http\Client\ClientInterface::class => ['Cakasim\Payone\Sdk\Http\StreamClient\StreamClient', true], + + // PSR-3 bindings, from cakasim/payone-sdk-silent-logger package + \Psr\Log\LoggerInterface::class => ['Cakasim\Payone\Sdk\Log\SilentLogger\SilentLogger', true], ]; /** diff --git a/src/Log/AbstractLogger.php b/src/Log/AbstractLogger.php deleted file mode 100644 index 34e3c2c..0000000 --- a/src/Log/AbstractLogger.php +++ /dev/null @@ -1,15 +0,0 @@ - - * @since 0.1.0 - */ -abstract class AbstractLogger extends \Psr\Log\AbstractLogger -{ -} diff --git a/src/Log/SilentLogger.php b/src/Log/SilentLogger.php deleted file mode 100644 index 05c8836..0000000 --- a/src/Log/SilentLogger.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @since 0.1.0 - */ -class SilentLogger extends AbstractLogger -{ - /** - * @inheritDoc - */ - public function log($level, $message, array $context = []): void - { - // Keep silence, *psst* - } -} diff --git a/tests/Log/SilentLoggerTest.php b/tests/Log/SilentLoggerTest.php deleted file mode 100644 index 4b9745f..0000000 --- a/tests/Log/SilentLoggerTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @since 0.1.0 - */ -class SilentLoggerTest extends TestCase -{ - /** - * @testdox The logger is silent - */ - public function testSilentLogger(): void - { - $logger = new SilentLogger(); - $this->assertInstanceOf(LoggerInterface::class, $logger); - - // Inspect SilentLogger to be actually silent. - // Check for exactly 3 lines of code. - $class = new ReflectionClass($logger); - $method = $class->getMethod('log'); - $this->assertEquals(3, $method->getEndLine() - $method->getStartLine()); - - // Check if the lines of code are silent. - $source = file($class->getFileName()); - $this->assertRegExp('~^\s*{\s*$~', $source[$method->getStartLine()]); - $this->assertRegExp('~^\s*//~', $source[$method->getStartLine() + 1]); - $this->assertRegExp('~^\s*}\s*$~', $source[$method->getStartLine() + 2]); - } -}