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

lmc-eu / matej-client-php / 7536558481

15 Jan 2024 01:31PM UTC coverage: 100.0%. Remained the same
7536558481

push

github

OndraM
Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

712 of 712 relevant lines covered (100.0%)

35.03 hits per line

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

100.0
/src/Model/Command/ItemsFilteringTrait.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Model\Command;
4

5
use Lmc\Matej\Model\Assertion;
6

7
trait ItemsFilteringTrait
8
{
9
    /** @var string */
10
    protected $filterOperator = 'and';
11
    /** @var string[] */
12
    private $filters;
13
    /** @var string[] */
14
    private $responseProperties;
15
    /** @var Boost[] */
16
    private $boosts = [];
17

18
    /**
19
     * Add a filter to already added filters (including the default filter).
20
     */
21
    public function addFilter(string $filter): self
22
    {
23
        if ($this->filters === null) {
14✔
24
            $this->filters = [];
14✔
25
        }
26
        $this->filters[] = $filter;
14✔
27

28
        return $this;
14✔
29
    }
30

31
    /**
32
     * Overwrite all filters by custom one. Note this will override also the default filter.
33
     */
34
    public function setFilters(array $filters): self
35
    {
36
        Assertion::allString($filters);
28✔
37

38
        $this->filters = $filters;
28✔
39

40
        return $this;
28✔
41
    }
42

43
    /**
44
     * Add another response property you want returned. item_id is always returned by Matej.
45
     */
46
    public function addResponseProperty(string $property): self
47
    {
48
        Assertion::typeIdentifier($property);
28✔
49

50
        if ($this->responseProperties === null) {
28✔
51
            $this->responseProperties = [];
28✔
52
        }
53
        $this->responseProperties[] = $property;
28✔
54

55
        return $this;
28✔
56
    }
57

58
    /**
59
     * Set all response properties you want returned. item_id is always returned by Matej, even when you don't specify
60
     * it.
61
     *
62
     * @param string[] $properties
63
     */
64
    public function setResponseProperties(array $properties): self
65
    {
66
        Assertion::allTypeIdentifier($properties);
14✔
67

68
        $this->responseProperties = $properties;
14✔
69

70
        return $this;
14✔
71
    }
72

73
    /**
74
     * Add a boost rule to already added rules.
75
     */
76
    public function addBoost(Boost $boost): self
77
    {
78
        $this->boosts[] = $boost;
28✔
79

80
        return $this;
28✔
81
    }
82

83
    /**
84
     * Set boosts. Removes all previously set rules.
85
     */
86
    public function setBoosts(array $boosts): self
87
    {
88
        $this->boosts = $boosts;
28✔
89

90
        return $this;
28✔
91
    }
92

93
    protected function assembleFiltersString(): string
94
    {
95
        return implode(' ' . $this->filterOperator . ' ', $this->filters);
28✔
96
    }
97

98
    protected function getSerializedBoosts(): array
99
    {
100
        return array_map(
28✔
101
            static function (Boost $boost) {
28✔
102
                return $boost->jsonSerialize();
28✔
103
            },
28✔
104
            $this->boosts
28✔
105
        );
28✔
106
    }
107

108
    protected function getItemsFilterParameters(): array
109
    {
110
        $parameters = [];
91✔
111

112
        if (!empty($this->boosts)) {
91✔
113
            $parameters['boost_rules'] = $this->getSerializedBoosts();
28✔
114
        }
115

116
        if ($this->filters !== null) {
91✔
117
            $parameters['filter'] = $this->assembleFiltersString();
28✔
118
        }
119

120
        if ($this->responseProperties !== null) {
91✔
121
            $parameters['properties'] = $this->responseProperties;
28✔
122
        }
123

124
        return $parameters;
91✔
125
    }
126
}
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