Passed
Push — hans/bufferadd ( 271d1a...b6965e )
by Simon
07:23
created

DocumentFactoryTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 69
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setItems() 0 5 1
A setClass() 0 5 1
A getItems() 0 3 1
A getFieldResolver() 0 3 1
A getClass() 0 3 1
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Traits;
5
6
use Firesphere\SolrSearch\Factories\DocumentFactory;
7
use Firesphere\SolrSearch\Helpers\FieldResolver;
8
use SilverStripe\ORM\ArrayList;
9
use SilverStripe\ORM\DataList;
10
11
/**
12
 * Trait DocumentFactoryTrait is a basic getter setter for the DocumentFactory.
13
 *
14
 * Getter and setter helpers
15
 *
16
 * @package Firesphere\SolrSearch\Traits
17
 */
18
trait DocumentFactoryTrait
19
{
20
    /**
21
     * @var FieldResolver Resolver for fields
22
     */
23
    protected $fieldResolver;
24
    /**
25
     * @var null|ArrayList|DataList Items to create documents for
26
     */
27
    protected $items;
28
    /**
29
     * @var string Current class that's being indexed
30
     */
31
    protected $class;
32
33
    /**
34
     * Current class being indexed
35
     *
36
     * @return string
37
     */
38 1
    public function getClass(): string
39
    {
40 1
        return $this->class;
41
    }
42
43
    /**
44
     * Set the current class to be indexed
45
     *
46
     * @param string $class
47
     * @return DocumentFactory
48
     */
49 6
    public function setClass(string $class): self
50
    {
51 6
        $this->class = $class;
52
53 6
        return $this;
54
    }
55
56
    /**
57
     * Get the FieldResolver class
58
     *
59
     * @return FieldResolver
60
     */
61 7
    public function getFieldResolver(): FieldResolver
62
    {
63 7
        return $this->fieldResolver;
64
    }
65
66
    /**
67
     * Get the items being indexed
68
     *
69
     * @return ArrayList|DataList|null
70
     */
71 6
    public function getItems()
72
    {
73 6
        return $this->items;
74
    }
75
76
    /**
77
     * Set the items to index
78
     *
79
     * @param ArrayList|DataList|null $items
80
     * @return DocumentFactory
81
     */
82 6
    public function setItems($items): self
83
    {
84 6
        $this->items = $items;
85
86 6
        return $this;
87
    }
88
}
89