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

contributte / datagrid / 10037097585

16 Jul 2024 04:34PM UTC coverage: 34.009%. First build
10037097585

push

github

f3l1x
Fix PHPStan issues

0 of 2 new or added lines in 1 file covered. (0.0%)

1124 of 3305 relevant lines covered (34.01%)

0.34 hits per line

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

0.0
/src/Utils/ItemDetailForm.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Utils;
4

5
use Nette\Application\UI\Presenter;
6
use Nette\ComponentModel\IComponent;
7
use Nette\Forms\Container;
8
use Nette\Forms\Form;
9
use Nette\Utils\Arrays;
10
use UnexpectedValueException;
11

12
final class ItemDetailForm extends Container
13
{
14

15
        /** @var callable */
16
        private $callableSetContainer;
17

18
        /** @var ?array */
19
        private ?array $httpPost = null;
20

21
        /** @var array<bool> */
22
        private array $containerSetByName = [];
23

24
        public function __construct(callable $callableSetContainer)
25
        {
26
                $this->monitor(
×
27
                        Presenter::class,
×
28
                        function (Presenter $presenter): void {
×
29
                                $this->loadHttpData();
30
                        }
×
31
                );
32

33
                $this->callableSetContainer = $callableSetContainer;
×
34
        }
35

36
        public function offsetGet(mixed $name): IComponent
37
        {
38
                return $this->getComponentAndSetContainer($name);
×
39
        }
40

41
        public function getComponentAndSetContainer(mixed $name): IComponent
42
        {
43
                $container = $this->addContainer($name);
×
44

45
                if (!isset($this->containerSetByName[$name])) {
×
46
                        call_user_func($this->callableSetContainer, $container);
×
47

48
                        $this->containerSetByName[$name] = true;
×
49
                }
50

51
                return $container;
×
52
        }
53

54
        /**
55
         * @throws UnexpectedValueException
56
         */
57
        private function getHttpData(): mixed
58
        {
59
                if ($this->httpPost === null) {
×
60
                        $lookupPath = $this->lookupPath(Form::class);
×
61
                        $form = $this->getForm();
×
62

63
                        $path = explode(self::NameSeparator, $lookupPath);
×
64

65
                        /** @var array $httpData */
NEW
66
                        $httpData = $form->getHttpData();
×
NEW
67
                        $this->httpPost = Arrays::get($httpData, $path, null);
×
68
                }
69

70
                return $this->httpPost;
×
71
        }
72

73
        /**
74
         * @throws UnexpectedValueException
75
         */
76
        private function loadHttpData(): void
77
        {
78
                $form = $this->getForm();
×
79

80
                if ($form->isSubmitted() === false) {
×
81
                        return;
×
82
                }
83

84
                foreach ((array) $this->getHttpData() as $name => $value) {
×
85
                        if ((is_iterable($value))) {
×
86
                                $this->getComponentAndSetContainer($name);
×
87
                        }
88
                }
89
        }
90

91
}
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