DocumentFactoryTrait   A
last analyzed

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
 * Trait DocumentFactoryTrait|Firesphere\SolrSearch\Traits\DocumentFactoryTrait A set of getters and setters to clean up
4
 * the actual {@link \Firesphere\SolrSearch\Factories\DocumentFactory} from clutter
5
 *
6
 * @package Firesphere\Solr\Search
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace Firesphere\SolrSearch\Traits;
12
13
use Firesphere\SolrSearch\Factories\DocumentFactory;
14
use Firesphere\SolrSearch\Helpers\FieldResolver;
15
use SilverStripe\ORM\ArrayList;
16
use SilverStripe\ORM\DataList;
17
18
/**
19
 * Trait DocumentFactoryTrait is a basic getter setter for the DocumentFactory.
20
 *
21
 * Getter and setter helpers
22
 *
23
 * @package Firesphere\Solr\Search
24
 */
25
trait DocumentFactoryTrait
26
{
27
    /**
28
     * @var FieldResolver Resolver for fields
29
     */
30
    protected $fieldResolver;
31
    /**
32
     * @var null|ArrayList|DataList Items to create documents for
33
     */
34
    protected $items;
35
    /**
36
     * @var string Current class that's being indexed
37
     */
38
    protected $class;
39
40
    /**
41
     * Current class being indexed
42
     *
43
     * @return string
44
     */
45 1
    public function getClass(): string
46
    {
47 1
        return $this->class;
48
    }
49
50
    /**
51
     * Set the current class to be indexed
52
     *
53
     * @param string $class
54
     * @return DocumentFactory
55
     */
56 8
    public function setClass(string $class): self
57
    {
58 8
        $this->class = $class;
59
60 8
        return $this;
61
    }
62
63
    /**
64
     * Get the FieldResolver class
65
     *
66
     * @return FieldResolver
67
     */
68 9
    public function getFieldResolver(): FieldResolver
69
    {
70 9
        return $this->fieldResolver;
71
    }
72
73
    /**
74
     * Get the items being indexed
75
     *
76
     * @return ArrayList|DataList|null
77
     */
78 8
    public function getItems()
79
    {
80 8
        return $this->items;
81
    }
82
83
    /**
84
     * Set the items to index
85
     *
86
     * @param ArrayList|DataList|null $items
87
     * @return DocumentFactory
88
     */
89 8
    public function setItems($items): self
90
    {
91 8
        $this->items = $items;
92
93 8
        return $this;
94
    }
95
}
96