Failed Conditions
Pull Request — release-11.1.x (#3164)
by
unknown
17:11
created

DomainObjectObserverRegistry   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 15
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 2
A isRegistered() 0 3 1
A getAll() 0 3 1
1
<?php
2
namespace ApacheSolrForTypo3\Solr\IndexQueue;
3
4
/**
5
 * DomainObject observer registry
6
 */
7
class DomainObjectObserverRegistry implements \TYPO3\CMS\Core\SingletonInterface
8
{
9
10
    /**
11
     * @var array
12
     */
13
    protected $domainObjectClassNames = [];
14
15
    /**
16
     *
17
     * @param string $domainObjectClassName
18
     */
19
    public function register(
20
        $domainObjectClassName
21
    ) {
22
        if (!is_subclass_of($domainObjectClassName, \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject::class)) {
23
            throw new \LogicException($domainObjectClassName . ' must be a subclass of AbstractDomainObject', 1519394042);
24
        }
25
26
        $this->domainObjectClassNames[$domainObjectClassName] = $domainObjectClassName;
27
    }
28
29
    /**
30
     * @param string $domainObjectClassName
31
     * @return bool
32
     */
33
    public function isRegistered($domainObjectClassName)
34
    {
35
        return isset($this->domainObjectClassNames[$domainObjectClassName]);
36
    }
37
38
    /**
39
     *
40
     * @return array
41
     */
42
    public function getAll()
43
    {
44
        return $this->domainObjectClassNames;
45
    }
46
}
47