FakeTransport   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 35
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findQuotes() 0 15 2
1
<?php
2
/**
3
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Api\Http;
7
8
use Jeancsil\FlightSpy\Api\DataTransfer\SessionParameters;
9
10
class FakeTransport implements TransportInterface
11
{
12
    const RESPONSE_FILE = 'skyscanner_response.json';
13
14
    /**
15
     * @var string
16
     */
17
    private $resourcesDir;
18
19
    public function __construct($resourcesDir)
20
    {
21
        $this->resourcesDir = $resourcesDir;
22
    }
23
24
    /**
25
     * @param SessionParameters $parameters
26
     * @param bool $newSession
27
     * @return \stdClass
28
     */
29
    public function findQuotes(SessionParameters $parameters, $newSession)
30
    {
31
        try {
32
            $contents = file_get_contents($this->resourcesDir . '/' . static::RESPONSE_FILE);
33
34
            $arrayContent = \GuzzleHttp\json_decode(
35
                str_replace("'", '\'', $contents),
36
                true
37
            );
38
39
            return (object) $arrayContent;
40
        } catch (\Exception $e) {
41
            // do nothing
42
        }
43
    }
44
}
45