From 793a8ff0b43c1eba8be639bc072f67f4e43a219a Mon Sep 17 00:00:00 2001 From: antonkomarev Date: Sun, 12 Jul 2020 12:15:03 +0300 Subject: [PATCH] Add CounterRepositoryInterface --- composer.json | 2 ++ composer.lock | 19 +++++++++++++++++++ contracts/CounterRepositoryInterface.php | 21 +++++++++++++++++++++ public/index.php | 3 +-- src/CounterFileRepository.php | 4 +++- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 composer.lock create mode 100644 contracts/CounterRepositoryInterface.php diff --git a/composer.json b/composer.json index a83fc95..6695cdd 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,13 @@ } ], "require": { + "php": "^7.4" }, "require-dev": { }, "autoload": { "psr-4": { + "Contracts\\Komarev\\GitHubProfileViewsCounter\\": "contracts/", "Komarev\\GitHubProfileViewsCounter\\": "src/" } }, diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..1e5c42e --- /dev/null +++ b/composer.lock @@ -0,0 +1,19 @@ +{ + "_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": "d6dfebb57666653dd233e3ce73e99b17", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": "^7.4" + }, + "platform-dev": [] +} diff --git a/contracts/CounterRepositoryInterface.php b/contracts/CounterRepositoryInterface.php new file mode 100644 index 0000000..c573249 --- /dev/null +++ b/contracts/CounterRepositoryInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Contracts\Komarev\GitHubProfileViewsCounter; + +interface CounterRepositoryInterface +{ + public function getCount(): int; + + public function incrementCount(): void; +} diff --git a/public/index.php b/public/index.php index 6af5672..d78b37c 100644 --- a/public/index.php +++ b/public/index.php @@ -18,8 +18,7 @@ $basePath = realpath(__DIR__ . '/..'); $resourcesPath = $basePath . '/resources'; $storagePath = $basePath . '/storage'; -require_once $basePath . '/src/CounterImageRendererService.php'; -require_once $basePath . '/src/CounterFileRepository.php'; +require $basePath . '/vendor/autoload.php'; $username = $_GET['username'] ?? ''; $username = trim($username); diff --git a/src/CounterFileRepository.php b/src/CounterFileRepository.php index eb3d4a9..152dafb 100644 --- a/src/CounterFileRepository.php +++ b/src/CounterFileRepository.php @@ -13,7 +13,9 @@ declare(strict_types=1); namespace Komarev\GitHubProfileViewsCounter; -final class CounterFileRepository +use Contracts\Komarev\GitHubProfileViewsCounter\CounterRepositoryInterface; + +final class CounterFileRepository implements CounterRepositoryInterface { private string $counterPath;