Verb   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 10 2
A fromModel() 0 15 3
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace XApi\Repository\Doctrine\Mapping;
13
14
use Xabbuh\XApi\Model\IRI;
15
use Xabbuh\XApi\Model\LanguageMap;
16
use Xabbuh\XApi\Model\Verb as VerbModel;
17
18
/**
19
 * A {@link Verb} mapped to a storage backend.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class Verb
24
{
25
    public $identifier;
26
27
    /**
28
     * @var string
29
     */
30
    public $id;
31
32
    /**
33
     * @var array|null
34
     */
35
    public $display;
36
37
    public function getModel()
38
    {
39
        $display = null;
40
41
        if (null !== $this->display) {
42
            $display = LanguageMap::create($this->display);
43
        }
44
45
        return new VerbModel(IRI::fromString($this->id), $display);
46
    }
47
48
    public static function fromModel(VerbModel $model)
49
    {
50
        $verb = new self();
51
        $verb->id = $model->getId()->getValue();
52
53
        if (null !== $display = $model->getDisplay()) {
54
            $verb->display = array();
55
56
            foreach ($display->languageTags() as $languageTag) {
57
                $verb->display[$languageTag] = $display[$languageTag];
58
            }
59
        }
60
61
        return $verb;
62
    }
63
}
64