Skip to content

Commit

Permalink
Merge pull request #12 from brainbits/chore/update-codestyle
Browse files Browse the repository at this point in the history
chore: update brainbits codestyle
  • Loading branch information
jojoguru authored Dec 7, 2022
2 parents 6c7e20f + 3e7afb4 commit 8ec3a97
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 50 deletions.
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":[],"times":{"Brainbits\\Blocking\\Tests\\BlockTest::testConstruct":0.03,"Brainbits\\Blocking\\Tests\\BlockTest::testGetIdentifierReturnsCorrectValue":0.001,"Brainbits\\Blocking\\Tests\\BlockTest::testGetOwnerReturnsCorrectValue":0,"Brainbits\\Blocking\\Tests\\BlockTest::testIsOwnedByReturnsTrue":0.001,"Brainbits\\Blocking\\Tests\\BlockTest::testIsOwnedByReturnsFalse":0.001,"Brainbits\\Blocking\\Tests\\BlockTest::testGetCreatedAtReturnsCorrectValue":0,"Brainbits\\Blocking\\Tests\\BlockTest::testGetUpdatedAtReturnsCreatedAtValueAfterInstanciation":0,"Brainbits\\Blocking\\Tests\\BlockTest::testTouchUpdatesValue":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testBlockReturnsBlockOnNonexistingBlock":0.005,"Brainbits\\Blocking\\Tests\\BlockerTest::testBlockReturnsBlockOnExistingAndInvalidBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testBlockThrowsExceptionOnExistingAndValidAndNonOwnerBlock":0.002,"Brainbits\\Blocking\\Tests\\BlockerTest::testBlockUpdatesBlockOnExistingAndValidAndOwnedBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testUnblockReturnsNullOnExistingAndInvalidBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testUnblockReturnsBlockOnExistingAndValidBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testUnblockReturnsNullOnNonexistingBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testIsBlockedReturnsFalseOnExistingAndInvalidBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testIsBlockedReturnsTrueOnExistingAndValidBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testIsBlockedReturnsFalseOnNonexistingBlock":0.001,"Brainbits\\Blocking\\Tests\\BlockerTest::testGetBlockReturnsBlockOnExistingBlock":0.001,"Brainbits\\Blocking\\Tests\\Identifier\\IdentifierTest::testConstruct":0,"Brainbits\\Blocking\\Tests\\Identifier\\IdentifierTest::testEquals":0,"Brainbits\\Blocking\\Tests\\Identifier\\IdentifierTest::testToString":0,"Brainbits\\Blocking\\Tests\\Owner\\OwnerTest::testConstruct":0,"Brainbits\\Blocking\\Tests\\Owner\\OwnerTest::testEquals":0,"Brainbits\\Blocking\\Tests\\Owner\\OwnerTest::testToString":0,"Brainbits\\Blocking\\Tests\\Owner\\SymfonySessionOwnerFactoryTest::testToString":0.012,"Brainbits\\Blocking\\Tests\\Owner\\SymfonyTokenOwnerFactoryTest::testCreateOwner":0.005,"Brainbits\\Blocking\\Tests\\Owner\\SymfonyTokenOwnerFactoryTest::testE":0,"Brainbits\\Blocking\\Tests\\Owner\\SymfonyTokenOwnerFactoryTest::testE2":0.001,"Brainbits\\Blocking\\Tests\\Owner\\ValueOwnerFactoryTest::testCreate":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testWriteSucceedesOnNewFile":0.007,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testWriteFailsOnNonExistantDirectoryInNonWritableDirectory":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testWriteFailsOnNonWritableDirectory":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testTouchSucceedesOnExistingFile":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testRemoveReturnsFalseOnNonexistingFile":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testUnblockReturnsTrueOnExistingFile":0.001,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testExistsReturnsFalseOnNonexistingFile":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testIsBlockedReturnsTrueOnExistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testGetReturnsNullOnNonexistingFile":0,"Brainbits\\Blocking\\Tests\\Storage\\FilesystemStorageTest::testGetReturnsBlockOnExistingFile":0.001,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testConstructWithBlock":0.001,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testWriteSucceedesOnNewBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testTouchSucceedesOnExistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testRemoveReturnsFalseOnNonexistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testUnblockReturnsTrueOnExistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testExistsReturnsFalseOnNonexistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testIsBlockedReturnsTrueOnExistingBlock":0,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testGetReturnsNullOnNonexistingFile":0.001,"Brainbits\\Blocking\\Tests\\Storage\\InMemoryStorageTest::testGetReturnsBlockOnExistingFile":0,"Brainbits\\Blocking\\Tests\\Validator\\AlwaysInvalidateValidatorTest::testValidateBlockLastUpdatedThirtySecondsAgo":0.001,"Brainbits\\Blocking\\Tests\\Validator\\AlwaysInvalidateValidatorTest::testValidateBlockLastUpdatedOneMinuteAgo":0,"Brainbits\\Blocking\\Tests\\Validator\\AlwaysInvalidateValidatorTest::testValidateBlockLastUpdatedOneHourAo":0,"Brainbits\\Blocking\\Tests\\Validator\\ExpiredValidatorTest::testValidateBlockLastUpdatedThirtySecondsAgo":0.001,"Brainbits\\Blocking\\Tests\\Validator\\ExpiredValidatorTest::testValidateBlockLastUpdatedOneMinuteAgo":0,"Brainbits\\Blocking\\Tests\\Validator\\ExpiredValidatorTest::testValidateBlockLastUpdatedOneHourAo":0}}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"symfony/security-core": "^5.4|^6.0",
"phpspec/prophecy-phpunit": "^2.0.1",
"squizlabs/php_codesniffer": "^3.6",
"brainbits/phpcs-standard": "^5.0",
"brainbits/phpcs-standard": "^6.0",
"phpstan/phpstan": "^1.0",
"brainbits/phpstan-rules": "^3.0"
},
Expand Down
13 changes: 5 additions & 8 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
*/
class Block implements BlockInterface
{
private IdentityInterface $identifier;
private OwnerInterface $owner;
private DateTimeImmutable $createdAt;
private DateTimeImmutable $updatedAt;

public function __construct(IdentityInterface $identifier, OwnerInterface $owner, DateTimeImmutable $createdAt)
{
$this->identifier = $identifier;
$this->owner = $owner;
$this->createdAt = $createdAt;
public function __construct(
private IdentityInterface $identifier,
private OwnerInterface $owner,
private DateTimeImmutable $createdAt,
) {
$this->updatedAt = $createdAt;
}

Expand Down
14 changes: 5 additions & 9 deletions src/Blocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@
class Blocker
{
private StorageInterface $storage;
private OwnerFactoryInterface $ownerFactory;
private ValidatorInterface $validator;

public function __construct(
StorageInterface $adapter,
OwnerFactoryInterface $ownerFactory,
ValidatorInterface $validator
private OwnerFactoryInterface $ownerFactory,
private ValidatorInterface $validator,
) {
$this->storage = $adapter;
$this->ownerFactory = $ownerFactory;
$this->validator = $validator;
}

public function block(IdentityInterface $identifier): BlockInterface
Expand All @@ -50,7 +46,7 @@ public function block(IdentityInterface $identifier): BlockInterface
return $block;
}

public function tryBlock(IdentityInterface $identifier): ?BlockInterface
public function tryBlock(IdentityInterface $identifier): BlockInterface|null
{
$owner = $this->ownerFactory->createOwner();

Expand All @@ -73,7 +69,7 @@ public function tryBlock(IdentityInterface $identifier): ?BlockInterface
return $block;
}

public function unblock(IdentityInterface $identifier): ?BlockInterface
public function unblock(IdentityInterface $identifier): BlockInterface|null
{
$block = $this->getBlock($identifier);
if ($block === null) {
Expand Down Expand Up @@ -104,7 +100,7 @@ public function isBlocked(IdentityInterface $identifier): bool
return false;
}

public function getBlock(IdentityInterface $identifier): ?BlockInterface
public function getBlock(IdentityInterface $identifier): BlockInterface|null
{
if (!$this->isBlocked($identifier)) {
return null;
Expand Down
6 changes: 1 addition & 5 deletions src/Exception/UnserializeFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@
*/
final class UnserializeFailedException extends RuntimeException
{
private string $input;

private function __construct(string $message, string $input)
private function __construct(string $message, private string $input)
{
parent::__construct($message);

$this->input = $input;
}

public static function createFromInput(mixed $input): self
Expand Down
5 changes: 1 addition & 4 deletions src/Identity/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/
class Identity implements IdentityInterface
{
private string $identityValue;

public function __construct(string $identityValue)
public function __construct(private string $identityValue)
{
$this->identityValue = $identityValue;
}

public function equals(IdentityInterface $identifier): bool
Expand Down
5 changes: 1 addition & 4 deletions src/Owner/Owner.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

class Owner implements OwnerInterface
{
private string $ownerValue;

public function __construct(string $ownerValue)
public function __construct(private string $ownerValue)
{
$this->ownerValue = $ownerValue;
}

public function equals(OwnerInterface $owner): bool
Expand Down
5 changes: 1 addition & 4 deletions src/Owner/SymfonySessionOwnerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
*/
class SymfonySessionOwnerFactory implements OwnerFactoryInterface
{
private RequestStack $requestStack;

public function __construct(RequestStack $requestStack)
public function __construct(private RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

public function createOwner(): OwnerInterface
Expand Down
5 changes: 1 addition & 4 deletions src/Owner/SymfonyTokenOwnerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
*/
class SymfonyTokenOwnerFactory implements OwnerFactoryInterface
{
private TokenStorageInterface $tokenStorage;

public function __construct(TokenStorageInterface $tokenStorage)
public function __construct(private TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}

public function createOwner(): OwnerInterface
Expand Down
5 changes: 1 addition & 4 deletions src/Owner/ValueOwnerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/
class ValueOwnerFactory implements OwnerFactoryInterface
{
private string $value;

public function __construct(string $value)
public function __construct(private string $value)
{
$this->value = $value;
}

public function createOwner(): OwnerInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/FilesystemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function exists(IdentityInterface $identifier): bool
return file_exists($filename);
}

public function get(IdentityInterface $identifier): ?BlockInterface
public function get(IdentityInterface $identifier): BlockInterface|null
{
if (!$this->exists($identifier)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/InMemoryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function exists(IdentityInterface $identifier): bool
return isset($this->blocks[(string) $identifier]);
}

public function get(IdentityInterface $identifier): ?BlockInterface
public function get(IdentityInterface $identifier): BlockInterface|null
{
if (!$this->exists($identifier)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public function remove(BlockInterface $block): bool;

public function exists(IdentityInterface $identifier): bool;

public function get(IdentityInterface $identifier): ?BlockInterface;
public function get(IdentityInterface $identifier): BlockInterface|null;
}
5 changes: 1 addition & 4 deletions src/Validator/ExpiredValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
*/
class ExpiredValidator implements ValidatorInterface
{
private int $expireSeconds;

public function __construct(int $expireSeconds)
public function __construct(private int $expireSeconds)
{
$this->expireSeconds = $expireSeconds;
}

public function validate(BlockInterface $block): bool
Expand Down

0 comments on commit 8ec3a97

Please sign in to comment.