ResponseConverter::convertResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\Episerver\Business\Api\Response;
9
10
use Generated\Shared\Transfer\EpiserverResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...iserverResponseTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Psr\Http\Message\ResponseInterface;
12
13
class ResponseConverter implements ResponseConverterInterface
14
{
15
    protected const STATUS_OK = 200;
16
17
    /**
18
     * @param \Psr\Http\Message\ResponseInterface $response
19
     *
20
     * @return \Generated\Shared\Transfer\EpiserverResponseTransfer
21
     */
22
    public function convertResponse(ResponseInterface $response): EpiserverResponseTransfer
23
    {
24
        $responseTransfer = new EpiserverResponseTransfer();
25
        $responseTransfer
26
            ->setStatus($response->getStatusCode())
27
            ->setIsSuccessful($this->isSuccessful($response));
28
29
        return $responseTransfer;
30
    }
31
32
    /**
33
     * @param \Psr\Http\Message\ResponseInterface $response
34
     *
35
     * @return bool
36
     */
37
    public function isSuccessful(ResponseInterface $response): bool
38
    {
39
        return $response->getStatusCode() === static::STATUS_OK;
40
    }
41
}
42