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.

AsArray   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
A map() 0 10 3
1
<?php
2
/**
3
 * Model
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\Model;
10
11
use Pimf\Contracts\Arrayable;
12
13
/**
14
 * Returns only protected and public properties of the given model-object. You have to extend it.
15
 *
16
 * Normally you will use ArrayObject and than method getArrayCopy() to turn Classes to Array, but
17
 * with AsArray you have the opportunity to easily intercept the setting of the values at the array.
18
 *
19
 * Sure if you need it - otherwise please prefers using ArrayObject - is much faster!
20
 *
21
 * @package Model
22
 * @author  Gjero Krsteski <[email protected]>
23
 */
24
abstract class AsArray implements Arrayable
25
{
26
    /**
27
     * Returns only protected and public properties of the given model-object.
28
     * For another properties output format, please override this method.
29
     *
30
     * @return array A list of properties.
31
     */
32
    public function toArray()
33
    {
34
        return $this->map(get_class_vars(get_class($this)));
35
    }
36
37
    /**
38
     * Maps the properties to array with actual values.
39
     * For another properties-mapping, please override this method.
40
     *
41
     * @param array $properties
42
     *
43
     * @return array
44
     */
45
    protected function map(array $properties)
46
    {
47
        $map = array();
48
49
        foreach ($properties as $name => $default) {
50
            $map[$name] = (true === empty($this->$name)) ? $default : $this->$name;
51
        }
52
53
        return $map;
54
    }
55
}
56