AbstractModel::toArray()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
3
/**
4
 * Abstract model
5
 */
6
7
namespace HDNET\Tagger\Domain\Model;
8
9
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
10
11
/**
12
 * Class AbstractModel
13
 */
14
class AbstractModel extends AbstractEntity
15
{
16
17
    /**
18
     * To array
19
     *
20
     * @return array
21
     */
22
    public function toArray()
23
    {
24
        $vars = [];
25
        $objectVars = array_keys(get_object_vars($this));
26
        foreach ($objectVars as $var) {
27
            if (method_exists($this, 'get' . ucfirst($var))) {
28
                $vars[$var] = call_user_func([$this, 'get' . ucfirst($var)]);
29
            }
30
        }
31
        return $vars;
32
    }
33
}
34