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

nette / component-model / 22884715739

04 Mar 2026 07:34AM UTC coverage: 87.444% (+0.3%) from 87.156%
22884715739

push

github

dg
made static analysis mandatory

195 of 223 relevant lines covered (87.44%)

0.87 hits per line

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

83.33
/src/ComponentModel/ArrayAccess.php
1
<?php declare(strict_types=1);
1✔
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
namespace Nette\ComponentModel;
9

10
use Nette;
11
use function is_int;
12

13

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

30

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

42

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

53

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