Completed
Branch master (23259a)
by Sergey
04:17 queued 48s
created

Error::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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