LivePrice::getMultiDeals()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 16
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 4
nop 1
crap 20
1
<?php
2
/**
3
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Api\Flights;
7
8
use Jeancsil\FlightSpy\Api\DataTransfer\SessionParameters;
9
use Jeancsil\FlightSpy\Api\Http\TransportAwareTrait;
10
11
class LivePrice
12
{
13
    use TransportAwareTrait;
14
15
    /**
16
     * @param SessionParameters $parameters
17
     * @param bool $newSession
18
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be \stdClass?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
19
     */
20
    public function getDeals(SessionParameters $parameters, $newSession)
21
    {
22
        return $this->transport->findQuotes($parameters, $newSession);
23
    }
24
25
    /**
26
     * @param array $sessionParameters
27
     * @return array
28
     */
29
    public function getMultiDeals(array $sessionParameters)
30
    {
31
        $responses = [];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32
        static $requests = 0;
33
        foreach ($sessionParameters as $sessionParameter) {
34
            if (!$sessionParameter instanceof SessionParameters) {
35
                throw new \LogicException(sprintf('Instance of SessionParameters need. Given %s.', $sessionParameter));
36
            }
37
38
            $newSession = ($requests % 20) == 0;
39
            if ($response = $this->getDeals($sessionParameter, $newSession)) {
40
                $responses[] = $response;
41
                $requests++;
42
            }
43
        }
44
45
        return $responses;
46
    }
47
}
48