Skip to content

Commit 8ec3a97

Browse files
authored
Merge pull request #12 from brainbits/chore/update-codestyle
chore: update brainbits codestyle
2 parents 6c7e20f + 3e7afb4 commit 8ec3a97

14 files changed

+22
-50
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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}}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/security-core": "^5.4|^6.0",
2121
"phpspec/prophecy-phpunit": "^2.0.1",
2222
"squizlabs/php_codesniffer": "^3.6",
23-
"brainbits/phpcs-standard": "^5.0",
23+
"brainbits/phpcs-standard": "^6.0",
2424
"phpstan/phpstan": "^1.0",
2525
"brainbits/phpstan-rules": "^3.0"
2626
},

src/Block.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@
2222
*/
2323
class Block implements BlockInterface
2424
{
25-
private IdentityInterface $identifier;
26-
private OwnerInterface $owner;
27-
private DateTimeImmutable $createdAt;
2825
private DateTimeImmutable $updatedAt;
2926

30-
public function __construct(IdentityInterface $identifier, OwnerInterface $owner, DateTimeImmutable $createdAt)
31-
{
32-
$this->identifier = $identifier;
33-
$this->owner = $owner;
34-
$this->createdAt = $createdAt;
27+
public function __construct(
28+
private IdentityInterface $identifier,
29+
private OwnerInterface $owner,
30+
private DateTimeImmutable $createdAt,
31+
) {
3532
$this->updatedAt = $createdAt;
3633
}
3734

src/Blocker.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@
2626
class Blocker
2727
{
2828
private StorageInterface $storage;
29-
private OwnerFactoryInterface $ownerFactory;
30-
private ValidatorInterface $validator;
3129

3230
public function __construct(
3331
StorageInterface $adapter,
34-
OwnerFactoryInterface $ownerFactory,
35-
ValidatorInterface $validator
32+
private OwnerFactoryInterface $ownerFactory,
33+
private ValidatorInterface $validator,
3634
) {
3735
$this->storage = $adapter;
38-
$this->ownerFactory = $ownerFactory;
39-
$this->validator = $validator;
4036
}
4137

4238
public function block(IdentityInterface $identifier): BlockInterface
@@ -50,7 +46,7 @@ public function block(IdentityInterface $identifier): BlockInterface
5046
return $block;
5147
}
5248

53-
public function tryBlock(IdentityInterface $identifier): ?BlockInterface
49+
public function tryBlock(IdentityInterface $identifier): BlockInterface|null
5450
{
5551
$owner = $this->ownerFactory->createOwner();
5652

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

76-
public function unblock(IdentityInterface $identifier): ?BlockInterface
72+
public function unblock(IdentityInterface $identifier): BlockInterface|null
7773
{
7874
$block = $this->getBlock($identifier);
7975
if ($block === null) {
@@ -104,7 +100,7 @@ public function isBlocked(IdentityInterface $identifier): bool
104100
return false;
105101
}
106102

107-
public function getBlock(IdentityInterface $identifier): ?BlockInterface
103+
public function getBlock(IdentityInterface $identifier): BlockInterface|null
108104
{
109105
if (!$this->isBlocked($identifier)) {
110106
return null;

src/Exception/UnserializeFailedException.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@
2121
*/
2222
final class UnserializeFailedException extends RuntimeException
2323
{
24-
private string $input;
25-
26-
private function __construct(string $message, string $input)
24+
private function __construct(string $message, private string $input)
2725
{
2826
parent::__construct($message);
29-
30-
$this->input = $input;
3127
}
3228

3329
public static function createFromInput(mixed $input): self

src/Identity/Identity.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
*/
1919
class Identity implements IdentityInterface
2020
{
21-
private string $identityValue;
22-
23-
public function __construct(string $identityValue)
21+
public function __construct(private string $identityValue)
2422
{
25-
$this->identityValue = $identityValue;
2623
}
2724

2825
public function equals(IdentityInterface $identifier): bool

src/Owner/Owner.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
class Owner implements OwnerInterface
1717
{
18-
private string $ownerValue;
19-
20-
public function __construct(string $ownerValue)
18+
public function __construct(private string $ownerValue)
2119
{
22-
$this->ownerValue = $ownerValue;
2320
}
2421

2522
public function equals(OwnerInterface $owner): bool

src/Owner/SymfonySessionOwnerFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
*/
2424
class SymfonySessionOwnerFactory implements OwnerFactoryInterface
2525
{
26-
private RequestStack $requestStack;
27-
28-
public function __construct(RequestStack $requestStack)
26+
public function __construct(private RequestStack $requestStack)
2927
{
30-
$this->requestStack = $requestStack;
3128
}
3229

3330
public function createOwner(): OwnerInterface

src/Owner/SymfonyTokenOwnerFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
*/
2424
class SymfonyTokenOwnerFactory implements OwnerFactoryInterface
2525
{
26-
private TokenStorageInterface $tokenStorage;
27-
28-
public function __construct(TokenStorageInterface $tokenStorage)
26+
public function __construct(private TokenStorageInterface $tokenStorage)
2927
{
30-
$this->tokenStorage = $tokenStorage;
3128
}
3229

3330
public function createOwner(): OwnerInterface

src/Owner/ValueOwnerFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
*/
1919
class ValueOwnerFactory implements OwnerFactoryInterface
2020
{
21-
private string $value;
22-
23-
public function __construct(string $value)
21+
public function __construct(private string $value)
2422
{
25-
$this->value = $value;
2623
}
2724

2825
public function createOwner(): OwnerInterface

0 commit comments

Comments
 (0)