Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Config
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
4 / 4
7
100.00% covered (success)
100.00%
1 / 1
 get
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 set
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
 has
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 remove
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Engelsystem\Config;
4
5use Illuminate\Support\Fluent;
6
7class Config extends Fluent
8{
9    /**
10     * The config values
11     */
12    protected $attributes = []; // phpcs:ignore
13
14    public function get(mixed $key, mixed $default = null): mixed
15    {
16        if (is_null($key)) {
17            return $this->attributes;
18        }
19
20        return parent::get($key, $default);
21    }
22
23    /**
24     * @param string|array $key
25     */
26    public function set(mixed $key, mixed $value = null): void
27    {
28        if (is_array($key)) {
29            foreach ($key as $configKey => $configValue) {
30                $this->set($configKey, $configValue);
31            }
32
33            return;
34        }
35
36        parent::set($key, $value);
37    }
38
39    /**
40     * @param string $key
41     */
42    public function has(mixed $key): bool
43    {
44        return data_has($this->attributes, $key);
45    }
46
47    /**
48     * @param string $key
49     */
50    public function remove(mixed $key): void
51    {
52        data_forget($this->attributes, $key);
53    }
54}