Precipitation::setData()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 15
ccs 0
cts 10
cp 0
rs 9.2
cc 4
eloc 9
nc 2
nop 1
crap 20
1
<?php
2
/**
3
 *
4
 * PHP version 5.5
5
 *
6
 * @package Forecast\Model
7
 * @author  Sergey V.Kuzin <[email protected]>
8
 * @license MIT
9
 */
10
declare(strict_types=1);
11
namespace Forecast\Model;
12
13
14
use Forecast\ForecastItemInterface;
15
16
class Precipitation implements ModelInterface
17
{
18
    /** @var  int */
19
    protected $probability;
20
21
    /** @var  float */
22
    protected $intensity;
23
24
    /** @var  float */
25
    protected $accumulation;
26
27
28
29
    /** @var  string */
30
    protected $type;
31
32
    /**
33
     * @return mixed
34
     */
35
    public function getIntensity()
36
    {
37
        return $this->intensity;
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43
    public function getProbability()
44
    {
45
        return $this->probability;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getType()
52
    {
53
        return $this->type;
54
    }
55
56
    /**
57
     * @api
58
     *
59
     * @return string
60
     */
61
    public function __toString()
62
    {
63
        return 'Вероятность дождя ' . $this->probability . '%';
64
    }
65
66
    /**
67
     * @param array $data
68
     * @return $this
69
     */
70 View Code Duplication
    public function setData(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        if (
73
            !($trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)) ||
74
            !(isset($trace[1]['class']) && in_array(ForecastItemInterface::class, class_implements($trace[1]['class'])))
75
        ) {
76
            trigger_error('Member not available: setData', E_USER_ERROR);
77
        }
78
79
        $this->intensity = $data['intensity'];
80
        $this->probability = $data['probability'];
81
        $this->type = $data['type'];
82
83
        return $this;
84
    }
85
}
86