Skip to content

Commit

Permalink
[CS][DX] Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylius Bot authored Jul 4, 2022
1 parent 8f477ca commit 7a14d8b
Show file tree
Hide file tree
Showing 1,203 changed files with 4,097 additions and 4,032 deletions.
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Behaviour/Toggles.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function assertCheckboxState(NodeElement $toggleableElement, $expectedSt
throw new \RuntimeException(sprintf(
"Toggleable element state is '%s' but expected '%s'.",
$toggleableElement->isChecked() ? 'true' : 'false',
$expectedState ? 'true' : 'false'
$expectedState ? 'true' : 'false',
));
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Sylius/Behat/Client/ApiPlatformClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
private SharedStorageInterface $sharedStorage,
private string $authorizationHeader,
private string $resource,
private ?string $section = null
private ?string $section = null,
) {
}

Expand Down Expand Up @@ -62,7 +62,7 @@ public function show(string $id): Response
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
));
}

Expand All @@ -83,7 +83,7 @@ public function delete(string $id): Response
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
));
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public function buildUpdateRequest(string $id): void
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
);
$this->request->setContent(json_decode($this->client->getResponse()->getContent(), true));
}
Expand All @@ -164,7 +164,7 @@ public function buildCustomUpdateRequest(string $id, string $customSuffix): void
$this->resource,
sprintf('%s/%s', $id, $customSuffix),
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
);
}

Expand Down Expand Up @@ -253,7 +253,7 @@ private function request(RequestInterface $request): Response
$request->parameters(),
$request->files(),
$request->headers(),
$request->content() ?? null
$request->content() ?? null,
);

return $this->getLastResponse();
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Client/ApiPlatformIriClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ApiPlatformIriClient implements ApiIriClientInterface
public function __construct(
private AbstractBrowser $client,
private SharedStorageInterface $sharedStorage,
private string $authorizationHeader
private string $authorizationHeader,
) {
}

Expand All @@ -43,7 +43,7 @@ private function request(RequestInterface $request): Response
$request->parameters(),
$request->files(),
$request->headers(),
$request->content() ?? null
$request->content() ?? null,
);

return $this->client->getResponse();
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Client/ApiPlatformSecurityClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ApiPlatformSecurityClient implements ApiSecurityClientInterface
public function __construct(
private AbstractBrowser $client,
private string $section,
private SharedStorageInterface $sharedStorage
private SharedStorageInterface $sharedStorage,
) {
}

Expand Down Expand Up @@ -52,7 +52,7 @@ public function call(): void
[],
[],
['CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json'],
json_encode($this->request['body'])
json_encode($this->request['body']),
);

$response = $this->client->getResponse();
Expand Down
30 changes: 15 additions & 15 deletions src/Sylius/Behat/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class Request implements RequestInterface
private function __construct(
private string $url,
private string $method,
array $headers = []
array $headers = [],
) {
$this->headers = array_merge($this->headers, $headers);
}
Expand All @@ -37,22 +37,22 @@ public static function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_GET,
$headers
$headers,
);
}

public static function subResourceIndex(?string $section, string $resource, string $id, string $subResource): RequestInterface
{
return new self(
sprintf('/api/v2/%s%s/%s/%s', self::prepareSection($section), $resource, $id, $subResource),
HttpRequest::METHOD_GET
HttpRequest::METHOD_GET,
);
}

Expand All @@ -61,22 +61,22 @@ public static function show(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_GET,
$headers
$headers,
);
}

public static function create(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'application/ld+json'];
if ($token !== null) {
Expand All @@ -86,7 +86,7 @@ public static function create(
return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_POST,
$headers
$headers,
);
}

Expand All @@ -95,7 +95,7 @@ public static function update(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'application/ld+json'];
if ($token !== null) {
Expand All @@ -105,7 +105,7 @@ public static function update(
return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_PUT,
$headers
$headers,
);
}

Expand All @@ -114,14 +114,14 @@ public static function delete(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_DELETE,
$headers
$headers,
);
}

Expand All @@ -135,15 +135,15 @@ public static function customItemAction(?string $section, string $resource, stri
return new self(
sprintf('/api/v2/%s%s/%s/%s', self::prepareSection($section), $resource, $id, $action),
$type,
['CONTENT_TYPE' => self::resolveHttpMethod($type)]
['CONTENT_TYPE' => self::resolveHttpMethod($type)],
);
}

public static function upload(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'multipart/form-data'];
if ($token !== null) {
Expand All @@ -153,7 +153,7 @@ public static function upload(
return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_POST,
$headers
$headers,
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Sylius/Behat/Client/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function subResourceIndex(?string $section, string $resource, string $id, string $subResource): self;
Expand All @@ -29,30 +29,30 @@ public static function show(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function create(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function update(
?string $section,
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function delete(
?string $section,
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function transition(?string $section, string $resource, string $id, string $transition): self;
Expand All @@ -63,7 +63,7 @@ public static function upload(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function custom(string $url, string $method, ?string $token = null): self;
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Client/ResponseChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@ private function getResponseContentValue(Response $response, string $key)
$content,
SprintfResponseEscaper::provideMessageWithEscapedResponseContent(
'Content could not be parsed to array.',
$response
)
$response,
),
);

Assert::keyExists(
$content,
$key,
SprintfResponseEscaper::provideMessageWithEscapedResponseContent(
'Expected \'' . $key . '\' not found.',
$response
)
$response,
),
);

return $content[$key];
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Api/Admin/AjaxContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class AjaxContext implements Context
{
public function __construct(
private AbstractBrowser $client,
private SessionInterface $session
private SessionInterface $session,
) {
}

Expand All @@ -39,7 +39,7 @@ public function iLookForVariantWithDescriptorWithinProduct($phrase, ProductInter
'/admin/ajax/product-variants/search',
['phrase' => $phrase, 'productCode' => $product->getCode()],
[],
['ACCEPT' => 'application/json']
['ACCEPT' => 'application/json'],
);
}

Expand Down
Loading

0 comments on commit 7a14d8b

Please sign in to comment.