Passed
Push — master ( e1aede...36be10 )
by Timo
33:39 queued 01:53
created

Document::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
rs 10
cc 2
nc 2
nop 2
crap 2.0185
1
<?php
2
namespace ApacheSolrForTypo3\Solr\System\Solr\Document;
3
4
use RuntimeException;
5
use Solarium\QueryType\Update\Query\Document\Document as SolariumDocument;
6
7
class Document extends SolariumDocument {
8
9
    /**
10
     * Magic call method used to emulate getters as used by the template engine.
11
     *
12
     * @param    string $name method name
13
     * @param    array $arguments method arguments
14
     * @return mixed
15
     */
16 7
    public function __call($name, $arguments)
17
    {
18 7
        if (substr($name, 0, 3) == 'get') {
19 7
            $field = substr($name, 3);
20 7
            $field = strtolower($field[0]) . substr($field, 1);
21 7
            return $this->fields[$field] ?? null;
22
        } else {
23
            throw new RuntimeException('Call to undefined method. Supports magic getters only.', 1311006605);
24
        }
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function getFieldNames()
31
    {
32
        return array_keys($this->fields);
33
    }
34
}