Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
94.12% |
16 / 17 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetQuery | |
94.12% |
16 / 17 |
|
50.00% |
1 / 2 |
4.00 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| tristateValue | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
3.07 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Controller; |
| 6 | |
| 7 | use Celemas\Core\Request; |
| 8 | |
| 9 | class GetQuery implements Query |
| 10 | { |
| 11 | use HasQueryProperties; |
| 12 | |
| 13 | public function __construct(Request $request) |
| 14 | { |
| 15 | $this->_map = $this->tristateValue($request->param('map', 'false')); |
| 16 | $this->_query = $request->param('query', null); |
| 17 | $this->_published = $this->tristateValue($request->param('published', null)); |
| 18 | $this->_hidden = $this->tristateValue($request->param('hidden', 'false')); |
| 19 | $this->_deleted = $this->tristateValue($request->param('deleted', 'false')); |
| 20 | $this->_content = $this->tristateValue($request->param('content', 'false')); |
| 21 | $this->_uids = array_map( |
| 22 | static fn(string $uid) => trim($uid), |
| 23 | explode(',', $request->param('uids', '')), |
| 24 | ); |
| 25 | $this->_order = $request->param('order', 'changed'); |
| 26 | $this->_fields = explode(',', $request->param('fields', '')); |
| 27 | } |
| 28 | |
| 29 | private function tristateValue(?string $value): ?bool |
| 30 | { |
| 31 | if ($value === 'true') { |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | if ($value === 'false') { |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | return null; |
| 40 | } |
| 41 | } |