• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

68publishers / file-storage / 3801321664

pending completion
3801321664

push

github

tg666
Tests + PHPStan level 9 + Dependency update

20 of 20 new or added lines in 10 files covered. (100.0%)

585 of 603 relevant lines covered (97.01%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.24
/src/Config/Config.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\FileStorage\Config;
6

7
use SixtyEightPublishers\FileStorage\Exception\InvalidArgumentException;
8
use SixtyEightPublishers\FileStorage\Exception\IllegalMethodCallException;
9
use function trim;
10
use function rtrim;
11
use function sprintf;
12
use function is_string;
13
use function array_merge;
14
use function array_key_exists;
15

16
class Config implements ConfigInterface
17
{
18
        /** @var array<string, mixed> */
19
        protected array $config = [
20
                self::BASE_PATH => '',
21
                self::HOST => null,
22
                self::VERSION_PARAMETER_NAME => '_v',
23
        ];
24

25
        /**
26
         * @param array<string, mixed> $config
27
         */
28
        public function __construct(array $config)
1✔
29
        {
30
                $this->config = array_merge($this->config, $config);
1✔
31

32
                // trim base path
33
                $this->config[self::BASE_PATH] = is_string($this->config[self::BASE_PATH]) ? trim($this->config[self::BASE_PATH], '/') : '';
1✔
34

35
                if (!empty($this->config[self::HOST]) && is_string($this->config[self::HOST])) {
1✔
36
                        $this->config[self::HOST] = rtrim($this->config[self::HOST], '/');
1✔
37
                }
38
        }
1✔
39

40
        public function offsetExists($offset): bool
41
        {
42
                return array_key_exists($offset, $this->config);
1✔
43
        }
44

45
        public function offsetGet($offset): mixed
46
        {
47
                if (!$this->offsetExists($offset)) {
1✔
48
                        throw new InvalidArgumentException(sprintf(
1✔
49
                                'Missing a configuration option "%s".',
1✔
50
                                $offset
1✔
51
                        ));
52
                }
53

54
                return $this->config[$offset];
1✔
55
        }
56

57
        public function offsetSet($offset, $value): never
58
        {
59
                throw IllegalMethodCallException::notAllowed(__METHOD__);
1✔
60
        }
×
61

62
        public function offsetUnset($offset): never
63
        {
64
                throw IllegalMethodCallException::notAllowed(__METHOD__);
1✔
65
        }
×
66

67
        /**
68
         * @return array<string, mixed>
69
         */
70
        public function jsonSerialize(): array
71
        {
72
                return $this->config;
1✔
73
        }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc