Completed
Push — master ( a35590...2bf349 )
by Anton
02:59
created

Decision::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
3
namespace Covery\Client\Requests;
4
5
use Covery\Client\EnvelopeInterface;
6
use Covery\Client\TransportInterface;
7
use GuzzleHttp\Psr7\Request;
8
9
/**
10
 * Class Decision
11
 *
12
 * Contains envelope to analyze with Covery
13
 *
14
 * @package Covery\Client\Requests
15
 */
16 View Code Duplication
class Decision extends Request
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    public function __construct(EnvelopeInterface $envelope)
19
    {
20
        // Building request
21
        $ids = array();
22
        foreach ($envelope->getIdentities() as $id) {
23
            $ids[] = $id->getType() . '=' . $id->getId();
24
        }
25
26
        $packet = array('type' => $envelope->getType(), 'sequence_id' => $envelope->getSequenceId());
27
28
        parent::__construct(
29
            'POST',
30
            TransportInterface::DEFAULT_URL . 'api/makeDecision',
31
            array(
32
                'X-Identities' => implode('&', $ids)
33
            ),
34
            json_encode(array_merge($packet, $envelope->toArray()))
35
        );
36
    }
37
}