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

ICanBoogie / Common / 6398009159

03 Oct 2023 08:19PM UTC coverage: 45.965% (+1.6%) from 44.407%
6398009159

push

github

olvlvl
Use named parameters for exceptions

26 of 26 new or added lines in 7 files covered. (100.0%)

131 of 285 relevant lines covered (45.96%)

2.28 hits per line

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

0.0
/lib/OffsetNotWritable.php
1
<?php
2

3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <olivier.laviale@gmail.com>
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 ICanBoogie;
13

14
use LogicException;
15
use Throwable;
16

17
/**
18
 * Exception thrown when an array offset is not writable.
19
 */
20
class OffsetNotWritable extends LogicException implements OffsetError
21
{
22
    /**
23
     * @phpstan-ignore-next-line
24
     */
25
    public function __construct(
26
        public readonly string|int $offset,
27
        public readonly array|object|null $container = null,
28
        string $message = null,
29
        Throwable $previous = null
30
    ) {
31
        if (!$message) {
×
32
            if (is_object($container)) {
×
33
                $message = format('The offset %offset for object of class %class is not writable.', [
×
34
                    'offset' => $offset,
×
35
                    'class' => get_class($container)
×
36
                ]);
×
37
            } elseif (is_array($container)) {
×
38
                $message = format('The offset %offset is not writable for the array: !array', [
×
39
                    'offset' => $offset,
×
40
                    'array' => $container
×
41
                ]);
×
42
            } else {
43
                $message = format('The offset %offset is not writable.', [
×
44
                    'offset' => $offset
×
45
                ]);
×
46
            }
47
        }
48

49
        parent::__construct($message, previous: $previous);
×
50
    }
51
}
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