ClassifiersResponse::getClassifiers()   B
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 9
nc 2
nop 0
crap 5
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 6
    public function getClassifiers()
25
    {
26 6
        if (!isset($this->classifiers)) {
27 6
            $classifiers = array();
28
29 6
            foreach ($this->data->classifiers as $classifier) {
30 6
                $owner = isset($classifier->owner) ? $classifier->owner : null;
31 6
                $created = isset($classifier->created) ? new DateTime($classifier->created): null;
32
33 6
                $classifiers[] = new Classifier($classifier->classifier_id, $classifier->name, null, $owner, $created);
34 6
            }
35
36 6
            $this->classifiers = $classifiers;
37 6
        }
38
39 6
        return $this->classifiers;
40
    }
41
}
42