GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

getObjectConverterExcludeFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Object converter trait
4
 *
5
 * @author Kachit
6
 */
7
namespace Kachit\Helper;
8
9
trait ObjectConverterTrait
10
{
11
    /**
12
     * To array
13
     *
14
     * @return array
15
     */
16
    public function toArray()
17
    {
18
        $vars = [];
19
        $excludeFields = $this->getObjectConverterExcludeFields();
20
        foreach ($this as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<Kachit\Helper\ObjectConverterTrait> is not traversable.
Loading history...
21
            if (!in_array($key, $excludeFields)) {
22
                $vars[$key] = ($this->checkClassParamIsObjectConverter($value)) ? $value->toArray() : $value;
23
            }
24
        }
25
        return $vars;
26
    }
27
28
    /**
29
     * Fill from array
30
     *
31
     * @param array $params
32
     * @return $this;
0 ignored issues
show
Documentation introduced by
The doc-type $this; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
33
     */
34
    public function fillFromArray(array $params)
35
    {
36
        $expectedParams = $this->toArray();
37
        foreach ($expectedParams as $key => $value) {
38
            if (array_key_exists($key, $params)) {
39
                $this->$key = $params[$key];
40
            } else {
41
                $this->$key = $value;
42
            }
43
        }
44
        return $this;
45
    }
46
47
    /**
48
     * Get object converter exclude fields
49
     *
50
     * @return array
51
     */
52
    protected function getObjectConverterExcludeFields()
53
    {
54
        return [];
55
    }
56
57
    /**
58
     * @param mixed $value
59
     * @return bool
60
     */
61
    protected function checkClassParamIsObjectConverter($value)
62
    {
63
        return (is_object($value) && method_exists($value, 'toArray') && method_exists($value, 'fillFromArray'));
64
    }
65
}