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

Error::getText()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 12
rs 9.4285
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