Code Duplication    Length = 23-28 lines in 2 locations

src/Manager/CaptureManager.php 1 location

@@ 9-31 (lines=23) @@
6
use Acquia\LiftClient\Entity\CapturesResponse;
7
use GuzzleHttp\Psr7\Request;
8
9
class CaptureManager extends ManagerBase
10
{
11
    /**
12
     * Add one or more captures.
13
     *
14
     * @see http://docs.decision-api.acquia.com/#capture_post
15
     *
16
     * @param \Acquia\LiftClient\Entity\Captures $captures
17
     *
18
     * @throws \GuzzleHttp\Exception\RequestException
19
     *
20
     * @return \Acquia\LiftClient\Entity\CapturesResponse
21
     */
22
    public function add(Captures $captures)
23
    {
24
        $body = $captures->json();
25
        $url = '/capture';
26
        $request = new Request('POST', $url, [], $body);
27
        $data = $this->client->getResponseJson($request);
28
29
        return new CapturesResponse($data);
30
    }
31
}
32

src/Manager/SegmentManager.php 1 location

@@ 8-35 (lines=28) @@
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
    public function query()
20
    {
21
        $url = '/segments';
22
23
        // Now make the request.
24
        $request = new Request('GET', $url);
25
        $data = $this->client->getResponseJson($request);
26
27
        // Get them as Segment objects
28
        $segments = [];
29
        foreach ($data as $dataItem) {
30
            $segments[] = new Segment($dataItem);
31
        }
32
33
        return $segments;
34
    }
35
}
36