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

ClassifiersResponse::getClassifiers()   B

Complexity

Conditions 5
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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