Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
GetQuery
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
 tristateValue
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Controller;
6
7use Celema\Core\Request;
8
9class 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}