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

Document::getFieldNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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
}