Document::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
    /**
26
     * @var DocumentData The document's data
27
     */
28
    private $data;
29
30
    public function __construct(DocumentData $data)
31
    {
32
        $this->data = $data;
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function offsetExists($offset)
39
    {
40
        return isset($this->data[$offset]);
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function offsetGet($offset)
47
    {
48
        return $this->data[$offset];
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function offsetSet($offset, $value)
55
    {
56
        $this->data[$offset] = $value;
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function offsetUnset($offset)
63
    {
64
        unset($this->data[$offset]);
65
    }
66
67
    /**
68
     * Returns the document's data.
69
     *
70
     * @return DocumentData The data
71
     */
72
    public function getData()
73
    {
74
        return $this->data;
75
    }
76
}
77