ClassifiersResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 30
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getClassifiers() 0 17 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