SegmentManager::query()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Acquia\LiftClient\Manager;
4
5
use Acquia\LiftClient\Entity\Segment;
6
use GuzzleHttp\Psr7\Request;
7
8
class SegmentManager extends ManagerBase
9
{
10
    /**
11
     * Get a list of Segments.
12
     *
13
     * @see http://docs.decision-api.acquia.com/#goals_get
14
     *
15
     * @throws \GuzzleHttp\Exception\RequestException
16
     *
17
     * @return \Acquia\LiftClient\Entity\Segment[]
18
     */
19 6
    public function query()
20
    {
21 6
        $url = '/segments';
22
23
        // Now make the request.
24 6
        $request = new Request('GET', $url);
25 6
        $data = $this->getResponseJson($request);
26
27
        // Get them as Segment objects
28 3
        $segments = [];
29 3
        foreach ($data as $dataItem) {
30 3
            $segments[] = new Segment($dataItem);
31 2
        }
32
33 3
        return $segments;
34
    }
35
}
36