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

contributte / datagrid / 8230157862

11 Mar 2024 09:02AM UTC coverage: 34.102%. First build
8230157862

Pull #1060

github

radimvaculik
Fix failing tests
Pull Request #1060: [7.x] Next

117 of 435 new or added lines in 54 files covered. (26.9%)

1124 of 3296 relevant lines covered (34.1%)

0.34 hits per line

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

30.43
/src/Filter/FilterRange.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Filter;
4

5
use Contributte\Datagrid\Datagrid;
6
use Nette\Forms\Container;
7

8
class FilterRange extends OneColumnFilter
9
{
10

11
        protected array $placeholders = [];
12

13
        protected ?string $template = 'datagrid_filter_range.latte';
14

15
        protected ?string $type = 'range';
16

17
        public function __construct(
1✔
18
                Datagrid $grid,
19
                string $key,
20
                string $name,
21
                string $column,
22
                protected string $nameSecond
23
        )
24
        {
25
                parent::__construct($grid, $key, $name, $column);
1✔
26
        }
1✔
27

28
        public function addToFormContainer(Container $container): void
29
        {
30
                $container = $container->addContainer($this->key);
×
31

32
                $from = $container->addText('from', $this->name);
×
33
                $to = $container->addText('to', $this->nameSecond);
×
34

35
                $this->addAttributes($from);
×
36
                $this->addAttributes($to);
×
37

38
                $placeholders = $this->getPlaceholders();
×
39

40
                if ($placeholders !== []) {
×
41
                        $text_from = reset($placeholders);
×
42

43
                        if ($text_from) {
×
NEW
44
                                $from->setHtmlAttribute('placeholder', $text_from);
×
45
                        }
46

47
                        $text_to = end($placeholders);
×
48

49
                        if ($text_to && ($text_to !== $text_from)) {
×
NEW
50
                                $to->setHtmlAttribute('placeholder', $text_to);
×
51
                        }
52
                }
53
        }
54

55
        /**
56
         * Set html attr placeholder of both inputs
57
         *
58
         * @return static
59
         */
60
        public function setPlaceholders(array $placeholders): self
61
        {
62
                $this->placeholders = $placeholders;
×
63

64
                return $this;
×
65
        }
66

67
        /**
68
         * Get html attr placeholders
69
         */
70
        public function getPlaceholders(): array
71
        {
72
                return $this->placeholders;
×
73
        }
74

75
        /**
76
         * Get filter condition
77
         */
78
        public function getCondition(): array
79
        {
80
                $value = $this->getValue();
1✔
81

82
                return [
83
                        $this->column => [
1✔
84
                                'from' => $value['from'] ?? '',
1✔
85
                                'to' => $value['to'] ?? '',
1✔
86
                        ],
87
                ];
88
        }
89

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