SegmentCommunication   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 42
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A fromArray() 0 24 5
1
<?php
2
3
namespace Audiens\DoubleclickClient\entity;
4
5
use Audiens\DoubleclickClient\exceptions\ReportException;
6
7
class SegmentCommunication extends Segment
8
{
9
    use HydratableTrait;
10
11
    public function __construct($segmentId, $segmentName, $segmentStatus, $size)
12
    {
13
        $this->size = $size;
14
15
        parent::__construct($segmentId, $segmentName, $segmentStatus);
16
    }
17
18
    /**
19
     * @param array $array
20
     *
21
     * @return static
22
     * @throws \Exception
23
     */
24
    public static function fromArray(array $array)
25
    {
26
        if (!isset($array['id'])) {
27
            throw ReportException::validation('hydration: id');
28
        }
29
30
        if (!isset($array['name'])) {
31
            throw ReportException::validation('hydration: name');
32
        }
33
34
        if (!isset($array['status'])) {
35
            throw ReportException::validation('hydration: status');
36
        }
37
        if (!isset($array['size'])) {
38
            throw ReportException::validation('hydration: size');
39
        }
40
41
        return new self(
42
            $array['id'],
43
            $array['name'],
44
            $array['status'],
45
            $array['size']
46
        );
47
    }
48
}
49