ServiceRequest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Osnova\Services;
4
5
class ServiceRequest
6
{
7
    public $count = 20;
8
    public $offset = 0;
9
10
    public function __construct(int $count = 20, int $offset = 0)
11
    {
12
        $this->count = $count;
13
        $this->offset = $offset;
14
    }
15
16
    /**
17
     * Get parameters for the current request.
18
     *
19
     * @return array
20
     */
21
    public function getParams()
22
    {
23
        $reflection = new \ReflectionClass($this);
24
        /** @var \ReflectionProperty[] $properties */
25
        $properties = array_filter($reflection->getProperties(), function (\ReflectionProperty $property) {
26
            return $property->isPublic();
27
        });
28
29
        $params = [];
30
31
        foreach ($properties as $property) {
32
            $params[$property->getName()] = $property->getValue($this);
33
        }
34
35
        return $params;
36
    }
37
}
38