Video::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 29
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 2
Metric Value
cc 5
eloc 12
c 4
b 0
f 2
nc 16
nop 7
dl 0
loc 29
rs 9.5555
1
<?php declare(strict_types=1);
2
3
namespace One\Model;
4
5
use One\Collection;
6
7
class Video extends Model
8
{
9
    /**
10
     * constructor
11
     *
12
     * @param \Psr\Http\Message\UriInterface|string $source
13
     * @param integer $order
14
     * @param \Psr\Http\Message\UriInterface|string $cover
15
     * @param string $lead
16
     */
17
    public function __construct(
18
        string $body,
19
        $source,
20
        $order,
21
        $cover = null,
22
        $lead = '',
23
        $duration = null,
24
        $ratio = ''
25
    ) {
26
        $properties = [
27
            'lead' => empty($lead) ? $this->createLeadFromBody($body) : $this->filterStringInstance($lead),
28
            'body' => $this->filterStringInstance($body),
29
            'order' => $order,
30
            'duration' => $duration
31
        ];
32
33
        if (! empty($source)) {
34
            $properties['source'] = $this->filterUriInstance($source);
35
        }
36
37
        if (! empty($cover)) {
38
            $properties['cover'] = $this->filterUriInstance($cover);
39
        }
40
41
        if (! empty($ratio)) {
42
            $properties['ratio'] = $this->filterStringInstance($ratio);
43
        }
44
45
        $this->collection = new Collection($properties);
46
    }
47
}
48