Completed
Push — master ( 6b7a3f...11cb20 )
by Sergey
02:13
created

Error   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 5
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getText() 0 12 3
A isEmpty() 0 4 1
1
<?php
2
3
namespace seregazhuk\PinterestBot\Api;
4
5
class Error
6
{
7
    /**
8
     * @var mixed
9
     */
10
    private $errorData;
11
12
    /**
13
     * @param array|null $errorData
14
     */
15
    public function __construct($errorData = null)
16
    {
17
        $this->errorData = $errorData;
18
    }
19
20
    /**
21
     * @return string|null
22
     */
23
    public function getText()
24
    {
25
        if(isset($this->errorData['message'])) {
26
            return $this->errorData['message'];
27
        }
28
29
        if(isset($this->errorData['code'])) {
30
            return $this->errorData['code'];
31
        }
32
33
        return null;
34
    }
35
36
    /**
37
     * @return bool
38
     */
39
    public function isEmpty()
40
    {
41
        return $this->errorData === null;
42
    }
43
}
44