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

Document   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 26
ccs 5
cts 8
cp 0.625
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 8 2
A getFieldNames() 0 3 1
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
}