• 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

75.0
/src/Filter/FilterText.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 FilterText extends Filter
9
{
10

11
        protected ?string $template = 'datagrid_filter_text.latte';
12

13
        protected ?string $type = 'text';
14

15
        protected bool $exact = false;
16

17
        protected bool $splitWordsSearch = true;
18

19
        /**
20
         * @param array|string[] $columns
21
         */
22
        public function __construct(
1✔
23
                Datagrid $grid,
24
                string $key,
25
                string $name,
26
                protected array $columns
27
        )
28
        {
29
                parent::__construct($grid, $key, $name);
1✔
30
        }
1✔
31

32
        /**
33
         * Adds text field to filter form
34
         */
35
        public function addToFormContainer(Container $container): void
36
        {
37
                $control = $container->addText($this->key, $this->name);
×
38

39
                $this->addAttributes($control);
×
40

41
                if ($this->getPlaceholder() !== null) {
×
NEW
42
                        $control->setHtmlAttribute('placeholder', $this->getPlaceholder());
×
43
                }
44
        }
45

46
        /**
47
         * Return array of conditions to put in result [column1 => value, column2 => value]
48
         *         If more than one column exists in fitler text,
49
         *         than there is OR clause put betweeen their conditions
50
         * Or callback in case of custom condition callback
51
         */
52
        public function getCondition(): array
53
        {
54
                return array_fill_keys($this->columns, $this->getValue());
1✔
55
        }
56

57
        public function isExactSearch(): bool
58
        {
59
                return $this->exact;
1✔
60
        }
61

62
        /**
63
         * @return static
64
         */
65
        public function setExactSearch(bool $exact = true): self
1✔
66
        {
67
                $this->exact = $exact;
1✔
68

69
                return $this;
1✔
70
        }
71

72
        /**
73
         * @return static
74
         */
75
        public function setSplitWordsSearch(bool $splitWordsSearch): self
1✔
76
        {
77
                $this->splitWordsSearch = $splitWordsSearch;
1✔
78

79
                return $this;
1✔
80
        }
81

82
        public function hasSplitWordsSearch(): bool
83
        {
84
                return $this->splitWordsSearch;
1✔
85
        }
86

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