Fact::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Yandex\Market\Content\Models;
4
5
use Yandex\Common\Model;
6
7
class Fact extends Model
8
{
9
    protected $fact = null;
10
11
    /**
12
     * Constructor
13
     *
14
     * @param array $data
15
     */
16 4
    public function __construct($data)
17
    {
18
        // fix for opinion pro & contra.
19 4
        if (is_string($data)) {
20 2
            $data = ['fact'=>$data];
21
        }
22
23 4
        parent::__construct($data);
24 4
    }
25
26 4
    public function __toString()
27
    {
28 4
        return (string) $this->fact;
29
    }
30
31
    /**
32
     * Retrieve the fact property
33
     *
34
     * @return string|null
35
     */
36
    public function getFact()
37
    {
38
        return $this->fact;
39
    }
40
}
41