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

nette / component-model / 11187771706

07 Aug 2024 12:35AM UTC coverage: 86.047%. Remained the same
11187771706

push

github

dg
improved phpDoc

185 of 215 relevant lines covered (86.05%)

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

14

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

31

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

43

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

54

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