Completed
Push — master ( ae5f67...a35590 )
by Anton
02:34
created

Event   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 2
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 Event
11
 *
12
 * Contains event data, that must be stored on Covery without
13
 * decision making
14
 *
15
 * @package Covery\Client\Requests
16
 */
17
class Event extends Request
18
{
19
    public function __construct(EnvelopeInterface $envelope)
20
    {
21
        // Building request
22
        $ids = array();
23
        foreach ($envelope->getIdentities() as $id) {
24
            $ids[] = $id->getType() . '=' . $id->getId();
25
        }
26
27
        $packet = array('type' => $envelope->getType(), 'sequence_id' => $envelope->getSequenceId());
28
29
        parent::__construct(
30
            'POST',
31
            TransportInterface::DEFAULT_URL . 'api/sendEvent',
32
            array(
33
                'X-Identities' => implode('&', $ids)
34
            ),
35
            json_encode(array_merge($packet, $envelope->toArray()))
36
        );
37
    }
38
}
39