ServiceRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getParams() 0 15 2
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