Completed
Push — develop ( fe8c75...3bcd98 )
by Tom
02:26
created

ClassifierResponse::getClassifier()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 8.8571
cc 6
eloc 11
nc 3
nop 0
1
<?php
2
3
namespace Bobbyshaw\WatsonVisualRecognition\Message;
4
5
use Bobbyshaw\WatsonVisualRecognition\Classifier;
6
use DateTime;
7
8
/**
9
 * Class ClassifierResponse
10
 * @package Bobbyshaw\WatsonVisualRecognition\Message
11
 */
12
class ClassifierResponse extends Response
13
{
14
    /**
15
     * @var Classifier
16
     */
17
    protected $classifier;
18
19
    /**
20
     * Get Classifiers
21
     *
22
     * @return Classifier
23
     */
24
    public function getClassifier()
25
    {
26
        if (!isset($this->classifier)) {
27
            if (isset($this->data->classifier_id) && isset($this->data->name) && isset($this->data->owner)
28
                && isset($this->data->created)
29
            ) {
30
                $this->classifier = new Classifier(
31
                    $this->data->classifier_id,
32
                    $this->data->name,
33
                    null,
34
                    $this->data->owner,
35
                    new DateTime($this->data->created)
36
                );
37
            }
38
        }
39
40
        return $this->classifier;
41
    }
42
}
43