Add CounterRepositoryInterface

This commit is contained in:
antonkomarev
2020-07-12 12:15:03 +03:00
parent 02397a195d
commit 793a8ff0b4
5 changed files with 46 additions and 3 deletions

View File

@@ -19,11 +19,13 @@
}
],
"require": {
"php": "^7.4"
},
"require-dev": {
},
"autoload": {
"psr-4": {
"Contracts\\Komarev\\GitHubProfileViewsCounter\\": "contracts/",
"Komarev\\GitHubProfileViewsCounter\\": "src/"
}
},

19
composer.lock generated Normal file
View File

@@ -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": []
}

View File

@@ -0,0 +1,21 @@
<?php
/*
* This file is part of GitHub Profile Views Counter.
*
* (c) Anton Komarev <anton@komarev.com>
*
* 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;
}

View File

@@ -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);

View File

@@ -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;