Skip to content

Commit

Permalink
refactor: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
aoekrz committed Jun 20, 2024
1 parent eb93fd1 commit 7330066
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 35 deletions.
8 changes: 3 additions & 5 deletions Classes/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@

abstract class AbstractCommand extends Command
{
protected FeatureFlagService $featureFlagService;

protected SymfonyStyle $inputOutput;

public function __construct(FeatureFlagService $featureFlagService)
{
public function __construct(
protected FeatureFlagService $featureFlagService
) {
parent::__construct();
$this->featureFlagService = $featureFlagService;
}

/**
Expand Down
8 changes: 3 additions & 5 deletions Classes/Domain/Repository/FeatureFlagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@

class FeatureFlagRepository extends Repository
{
private FeatureFlagData $featureFlagData;

public function __construct(FeatureFlagData $featureFlagData)
{
$this->featureFlagData = $featureFlagData;
public function __construct(
private readonly FeatureFlagData $featureFlagData
) {
parent::__construct();
}

Expand Down
15 changes: 3 additions & 12 deletions Classes/Service/FeatureFlagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,13 @@ class FeatureFlagService
*/
public const BEHAVIOR_SHOW = 1;

private FeatureFlagRepository $featureFlagRepository;

private PersistenceManagerInterface $persistenceManager;

private Configuration $configuration;

private array $cachedFlags = [];

public function __construct(
FeatureFlagRepository $featureFlagRepository,
PersistenceManagerInterface $persistenceManager,
Configuration $configuration
private readonly FeatureFlagRepository $featureFlagRepository,
private readonly PersistenceManagerInterface $persistenceManager,
private readonly Configuration $configuration
) {
$this->featureFlagRepository = $featureFlagRepository;
$this->persistenceManager = $persistenceManager;
$this->configuration = $configuration;
}

public function isFeatureEnabled(string $flag): bool
Expand Down
2 changes: 1 addition & 1 deletion Classes/System/Typo3/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(ExtensionConfiguration $extensionConfiguration)

public function getTables(): array
{
return explode(',', $this->get(self::CONF_TABLES));
return explode(',', (string) $this->get(self::CONF_TABLES));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/System/Typo3/TcaPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function getTcaTablesWithFeatureFlagSupport(): array
$config = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('feature_flag');

if (isset($config['tables'])) {
return explode(',', $config['tables']);
return explode(',', (string) $config['tables']);
}

return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function testShouldShowElementForBehaviorHideAndDisabledFeatureFlag(): vo
$this->assertSame(0, $contentElements[0]['hidden']);
}


public function getElementsData(string $table, int $uid): array
{
/** @var QueryBuilder $queryBuilder */
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Command/AbstractCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function assertThatFeaturesAreNotActivated()

protected function assertThatFeaturesAreDeactivated(array $expectedFeatures)
{
$this->assertEquals($expectedFeatures, $this->deactivatedFeatures);
$this->assertSame($expectedFeatures, $this->deactivatedFeatures);
}

/**
Expand All @@ -98,7 +98,7 @@ protected function assertThatFeaturesAreNotDeactivated()

protected function assertThatInfosAreShown(array $expectedInfos)
{
$this->assertEquals($expectedInfos, $this->shownInfos);
$this->assertSame($expectedInfos, $this->shownInfos);
}

protected function runCommand(string $commandClass, string $commaSeparatedListOfFeatures = '')
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Domain/Model/FeatureFlagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testCheckProperties(): void
$this->featureFlag->setEnabled(true);
$this->featureFlag->setFlag('my_new_feature_flag');
$this->assertTrue($this->featureFlag->isEnabled());
$this->assertEquals($this->featureFlag->getDescription(), 'This is a test description');
$this->assertEquals($this->featureFlag->getFlag(), 'my_new_feature_flag');
$this->assertSame('This is a test description', $this->featureFlag->getDescription());
$this->assertSame('my_new_feature_flag', $this->featureFlag->getFlag());
}
}
12 changes: 6 additions & 6 deletions Tests/Unit/Domain/Model/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ protected function tearDown(): void
public function testTstamp(): void
{
$this->mapping->setTstamp(2183466346);
$this->assertEquals(2183466346, $this->mapping->getTstamp());
$this->assertSame('2183466346', $this->mapping->getTstamp());
}

public function testCrdate(): void
{
$this->mapping->setCrdate(2183466347);
$this->assertEquals(2183466347, $this->mapping->getCrdate());
$this->assertSame('2183466347', $this->mapping->getCrdate());
}

public function testFeatureFlag(): void
Expand All @@ -72,25 +72,25 @@ public function testFeatureFlag(): void
$featureFlag->method('getFlag')
->willReturn('my_awesome_feature_flag');
$this->mapping->setFeatureFlag($featureFlag);
$this->assertEquals('my_awesome_feature_flag', $this->mapping->getFeatureFlag()->getFlag());
$this->assertSame('my_awesome_feature_flag', $this->mapping->getFeatureFlag()->getFlag());
}

public function testForeignTableColumn(): void
{
$this->mapping->setForeignTableColumn('my_foreign_column');
$this->assertEquals('my_foreign_column', $this->mapping->getForeignTableColumn());
$this->assertSame('my_foreign_column', $this->mapping->getForeignTableColumn());
}

public function testForeignTableName(): void
{
$this->mapping->setForeignTableName('my_foreign_table');
$this->assertEquals('my_foreign_table', $this->mapping->getForeignTableName());
$this->assertSame('my_foreign_table', $this->mapping->getForeignTableName());
}

public function testForeignTableUid(): void
{
$this->mapping->setForeignTableUid(4711);
$this->assertEquals(4711, $this->mapping->getForeignTableUid());
$this->assertSame(4711, $this->mapping->getForeignTableUid());
}

public function testBehavior(): void
Expand Down

0 comments on commit 7330066

Please sign in to comment.