Skip to content

Commit

Permalink
Align multiple subsequent assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Aug 29, 2024
1 parent 260b9f1 commit da4a2c2
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions inc/Data/ThirdPartyDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ThirdPartyDataFormatter
*/
public static function formatData(ThirdPartyData $data, array $args): ThirdPartyOutput
{
$htmlData = $data->getHtml();
$htmlData = $data->getHtml();
$scriptsData = $data->getScripts();

$allScriptParams = array_reduce(
Expand Down Expand Up @@ -169,7 +169,7 @@ public static function formatUrl(string $url, array $params, array $args, array
$path = parse_url($url, PHP_URL_PATH);
if ($path) {
$trailingSlash = str_ends_with($path, '/') ? '/' : '';
$url = str_replace(
$url = str_replace(
$path,
substr($path, 0, - strlen(basename($path) . $trailingSlash)) . $slug . $trailingSlash,
$url
Expand Down
4 changes: 2 additions & 2 deletions inc/Data/ThirdPartySrcValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function __construct(array $srcData)
throw new InvalidThirdPartyDataException('Missing src url.');
}

$this->url = $srcData['url'];
$this->url = $srcData['url'];
$this->slugParam = isset($srcData['slugParam']) ? (string) $srcData['slugParam'] : '';
$this->params = isset($srcData['params']) ? array_map('strval', $srcData['params']) : [];
$this->params = isset($srcData['params']) ? array_map('strval', $srcData['params']) : [];
}

/**
Expand Down
2 changes: 2 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
</properties>
</rule>

<rule ref="Generic.Formatting.MultipleStatementAlignment"/>

<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Data/ThirdPartyDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function testToArray()
],
'stylesheets' => ['https://example.com/style.css', 'https://example.com/style-2.css'],
];
$data = new ThirdPartyData($input);
$data = new ThirdPartyData($input);
$this->assertSame($input, $data->toArray());
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Data/ThirdPartyHtmlDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function dataGetMethods()

public function testToArray()
{
$input = [
$input = [
'element' => 'iframe',
'attributes' => [
'src' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Data/ThirdPartyOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function dataGetMethods()

public function testToArray()
{
$input = [
$input = [
'id' => 'my-service',
'description' => 'A service that allows embedding something.',
'website' => 'https://my-service.com/',
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/tests/Data/ThirdPartyScriptDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public function dataGetMethods()

public function testConstructorWithUrlAndNoCode()
{
$data = ['url' => 'https://example.com/'];
$data = ['url' => 'https://example.com/'];
$scriptData = new ThirdPartyScriptData(array_merge($this->baseData, $data));

$this->assertSame($data['url'], $scriptData->getUrl());
}

public function testConstructorWithCodeAndNoUrl()
{
$data = ['code' => 'window.dataLayer=window.dataLayer'];
$data = ['code' => 'window.dataLayer=window.dataLayer'];
$scriptData = new ThirdPartyScriptData(array_merge($this->baseData, $data));

$this->assertSame($data['code'], $scriptData->getCode());
Expand All @@ -101,7 +101,7 @@ public function testConstructorWithUrlAndCode()
{
$this->expectException(InvalidThirdPartyDataException::class);

$data = [
$data = [
'url' => 'https://example.com/',
'code' => 'window.dataLayer=window.dataLayer',
];
Expand Down Expand Up @@ -137,7 +137,7 @@ public function dataIsExternal()

public function testToArray()
{
$input = array_merge(
$input = array_merge(
$this->baseData,
[
'url' => 'https://example.com/',
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Data/ThirdPartyScriptOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function dataGetMethods()

public function testToArray()
{
$input = [
$input = [
'strategy' => ThirdPartyScriptData::STRATEGY_CLIENT,
'location' => ThirdPartyScriptData::LOCATION_HEAD,
'action' => ThirdPartyScriptData::ACTION_APPEND,
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Data/ThirdPartySrcValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function dataGetMethods()

public function testToArray()
{
$input = [
$input = [
'url' => 'https://my-embed.com',
'slugParam' => 'type',
'params' => ['id', 'mode'],
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Util/HtmlAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testOffsetUnset()

public function testGetIterator()
{
$attrs = new HtmlAttributes([
$attrs = new HtmlAttributes([
'id' => 'unique-id',
'class' => 'test-class',
]);
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/utils/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function runGetterTestCase(string $className, string $getMethod, array
}

$instance = new $className($args);
$result = call_user_func([$instance, $getMethod]);
$result = call_user_func([$instance, $getMethod]);
if ($result instanceof Arrayable) {
$result = $result->toArray();
} elseif (is_array($result)) {
Expand Down Expand Up @@ -57,7 +57,7 @@ protected function gettersToTestCases(array $getters, string $exceptionClass = n
}

if (!isset($getter['value'])) {
$type = isset($getter['default']) ? gettype($getter['default']) : 'string';
$type = isset($getter['default']) ? gettype($getter['default']) : 'string';
$value = $this->createValueOfType($type);
} else {
$value = $getter['value'];
Expand All @@ -68,12 +68,12 @@ protected function gettersToTestCases(array $getters, string $exceptionClass = n
$testCases = [];
foreach ($getters as $getter) {
if (!isset($getter['value'])) {
$type = isset($getter['default']) ? gettype($getter['default']) : 'string';
$type = isset($getter['default']) ? gettype($getter['default']) : 'string';
$value = $this->createValueOfType($type);
} else {
$value = $getter['value'];
}
$args = $requiredFields;
$args = $requiredFields;
$args[$getter['field']] = $value;

$testCases["{$getter['getter']} with value"] = [
Expand Down

0 comments on commit da4a2c2

Please sign in to comment.