Page::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 24
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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