Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
ArrayAccessConfigTrait
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 offsetExists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetGet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetUnset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of php-fast-forward/config.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @link      https://github.com/php-fast-forward/config
12 * @copyright Copyright (c) 2025 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
13 * @license   https://opensource.org/licenses/MIT MIT License
14 */
15
16namespace FastForward\Config;
17
18use Dflydev\DotAccessData\Data;
19
20/**
21 * Trait ArrayAccessConfigTrait.
22 *
23 * This trait provides array-like access to configuration data.
24 * It MUST be used in classes that implement \ArrayAccess and provide
25 * the corresponding methods: `get`, `set`, `has`, and `remove`.
26 *
27 * @internal
28 *
29 * @see \ArrayAccess
30 */
31trait ArrayAccessConfigTrait
32{
33    /**
34     * Determines whether the given offset exists in the configuration data.
35     *
36     * This method SHALL return true if the offset is present, false otherwise.
37     *
38     * @param mixed $offset the offset to check for existence
39     *
40     * @return bool true if the offset exists, false otherwise
41     */
42    public function offsetExists(mixed $offset): bool
43    {
44        return $this->has($offset);
45    }
46
47    /**
48     * Retrieves the value associated with the given offset.
49     *
50     * This method MUST return the value mapped to the specified offset.
51     * If the offset does not exist, behavior SHALL depend on the implementation
52     * of the `get` method.
53     *
54     * @param mixed $offset the offset to retrieve
55     *
56     * @return mixed the value at the given offset
57     */
58    public function offsetGet(mixed $offset): mixed
59    {
60        return $this->get($offset);
61    }
62
63    /**
64     * Sets the value for the specified offset.
65     *
66     * This method SHALL assign the given value to the specified offset.
67     *
68     * @param mixed $offset the offset at which to set the value
69     * @param mixed $value  the value to set
70     */
71    public function offsetSet(mixed $offset, mixed $value): void
72    {
73        $this->set($offset, $value);
74    }
75
76    /**
77     * Unsets the specified offset.
78     *
79     * This method SHALL remove the specified offset and its associated value.
80     *
81     * @param mixed $offset the offset to remove
82     */
83    public function offsetUnset(mixed $offset): void
84    {
85        $this->remove($offset);
86    }
87}