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

nette / component-model / 21197986702

21 Jan 2026 05:06AM UTC coverage: 86.425% (+0.2%) from 86.256%
21197986702

push

github

dg
added CLAUDE.md

191 of 221 relevant lines covered (86.43%)

0.86 hits per line

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

81.82
/src/ComponentModel/ArrayAccess.php
1
<?php
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Nette\ComponentModel;
11

12
use Nette;
13
use function is_int;
14

15

16
/**
17
 * Implementation of \ArrayAccess for IContainer.
18
 */
19
trait ArrayAccess
20
{
21
        /**
22
         * Adds the component to the container.
23
         * @param  string|int  $name
24
         * @param  IComponent  $component
25
         */
26
        public function offsetSet($name, $component): void
27
        {
28
                $name = is_int($name) ? (string) $name : $name;
1✔
29
                $this->addComponent($component, $name);
1✔
30
        }
1✔
31

32

33
        /**
34
         * Returns component specified by name. Throws exception if component doesn't exist.
35
         * @param  string|int  $name
36
         * @throws Nette\InvalidArgumentException
37
         */
38
        public function offsetGet($name): IComponent
39
        {
40
                $name = is_int($name) ? (string) $name : $name;
1✔
41
                return $this->getComponent($name);
1✔
42
        }
43

44

45
        /**
46
         * Does component specified by name exists?
47
         * @param  string|int  $name
48
         */
49
        public function offsetExists($name): bool
50
        {
51
                $name = is_int($name) ? (string) $name : $name;
×
52
                return $this->getComponent($name, throw: false) !== null;
×
53
        }
54

55

56
        /**
57
         * Removes component from the container.
58
         * @param  string|int  $name
59
         */
60
        public function offsetUnset($name): void
61
        {
62
                $name = is_int($name) ? (string) $name : $name;
1✔
63
                if ($component = $this->getComponent($name, throw: false)) {
1✔
64
                        $this->removeComponent($component);
1✔
65
                }
66
        }
1✔
67
}
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

© 2026 Coveralls, Inc