Document   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 49
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
A getData() 0 4 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 Xabbuh\XApi\Model;
13
14
/**
15
 * An Experience API document.
16
 *
17
 * A document is immutable. This means that it can be accessed like an array.
18
 * But you can only do this to read data. Thus an {@link UnsupportedOperationException}
19
 * is thrown when you try to unset data or to manipulate them.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
abstract class Document implements \ArrayAccess
24
{
25
    private $data;
26
27
    public function __construct(DocumentData $data)
28
    {
29
        $this->data = $data;
30 12
    }
31
32 12
    /**
33 12
     * {@inheritDoc}
34
     */
35
    public function offsetExists($offset): bool
36
    {
37
        return isset($this->data[$offset]);
38 3
    }
39
40 3
    /**
41
     * {@inheritDoc}
42
     */
43
    public function offsetGet($offset)
44
    {
45
        return $this->data[$offset];
46 3
    }
47
48 3
    /**
49
     * {@inheritDoc}
50
     */
51
    public function offsetSet($offset, $value): void
52
    {
53
        $this->data[$offset] = $value;
54 3
    }
55
56 3
    /**
57
     * {@inheritDoc}
58
     */
59
    public function offsetUnset($offset): void
60
    {
61
        unset($this->data[$offset]);
62 3
    }
63
64 3
    /**
65
     * Returns the document's data.
66
     */
67
    public function getData(): DocumentData
68
    {
69
        return $this->data;
70
    }
71
}
72