Completed
Push — master ( c233b7...aa3611 )
by Christian
02:29
created

MappedStatement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 62
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A createFromModel() 0 14 1
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\Api\Mapping;
13
14
use Xabbuh\XApi\Model\Actor;
15
use Xabbuh\XApi\Model\Result;
16
use Xabbuh\XApi\Model\Statement;
17
18
/**
19
 * A {@link Statement} mapped to a storage backend.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class MappedStatement
24
{
25
    /**
26
     * @var string
27
     */
28
    public $id;
29
30
    /**
31
     * @var Actor
32
     */
33
    public $actor;
34
35
    /**
36
     * @var MappedVerb
37
     */
38
    public $verb;
39
40
    /**
41
     * @var \Xabbuh\XApi\Model\Object
42
     */
43
    public $object;
44
45
    /**
46
     * @var Result
47
     */
48
    public $result;
49
50
    /**
51
     * @var Actor
52
     */
53
    public $authority;
54
55
    /**
56
     * @var \DateTime
57
     */
58
    public $created;
59
60
    /**
61
     * @var \DateTime
62
     */
63
    public $stored;
64
65
    public function getModel()
66
    {
67
        return new Statement($this->id, $this->actor, $this->verb->getModel(), $this->object, $this->result, $this->authority, $this->created, $this->stored);
68
    }
69
70
    public static function createFromModel(Statement $statement)
71
    {
72
        $mappedStatement = new MappedStatement();
73
        $mappedStatement->id = $statement->getId();
74
        $mappedStatement->actor = $statement->getActor();
75
        $mappedStatement->verb = MappedVerb::createFromModel($statement->getVerb());
76
        $mappedStatement->object = $statement->getObject();
77
        $mappedStatement->result = $statement->getResult();
78
        $mappedStatement->authority = $statement->getAuthority();
79
        $mappedStatement->created = $statement->getCreated();
80
        $mappedStatement->stored = $statement->getStored();
81
82
        return $mappedStatement;
83
    }
84
}
85