ArrayAccessTrait::get()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Di
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Di\Traits;
16
17
/**
18
 * ArrayAccessTrait
19
 *
20
 * Array access for container
21
 *
22
 * @package Phossa2\Di
23
 * @author  Hong Zhang <[email protected]>
24
 * @see     \ArrayAccess
25
 * @version 2.0.0
26
 * @since   2.0.0 added
27
 */
28
trait ArrayAccessTrait
29
{
30
    public function offsetExists($offset)/*# : bool */
31
    {
32
        return $this->has($offset);
33
    }
34
35
    public function offsetGet($offset)
36
    {
37
        return $this->get($offset);
38
    }
39
40
    public function offsetSet($offset, $value)
41
    {
42
        $this->set($offset, $value);
43
    }
44
45
    public function offsetUnset($offset)
46
    {
47
        $this->offsetSet($offset, null);
48
    }
49
50
    // ContainerInterface related
51
52
    /**
53
     * @return bool
54
     */
55
    abstract public function has(/*# string */ $id)/*# : bool */;
56
    /**
57
     * @return mixed|null
58
     */
59
    abstract public function get(/*# string */ $id);
60
61
    // WritableInterface related
62
    /**
63
     * @return bool
64
     */
65
    abstract public function set(/*# string */ $id, $value)/*# : bool */;
66
}
67