GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractTransformer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 64
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A validateEntityClass() 0 6 2
A transformToDocuments() 0 12 2
A transformToIds() 0 12 2
handleTransformToDocuments() 0 1 ?
handleTransformToIds() 0 1 ?
1
<?php
2
3
namespace Nimble\ElasticBundle\Transformer;
4
5
use Nimble\ElasticBundle\Document;
6
use Nimble\ElasticBundle\Exception\UnexpectedTypeException;
7
8
abstract class AbstractTransformer implements TransformerInterface
9
{
10
    /**
11
     * @param object $entity
12
     */
13
    private function validateEntityClass($entity)
14
    {
15
        if (!is_a($entity, $this->getClass())) {
16
            throw new UnexpectedTypeException($entity, $this->getClass());
17
        }
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function transformToDocuments($entity)
24
    {
25
        $this->validateEntityClass($entity);
26
27
        $documents = $this->handleTransformToDocuments($entity);
28
29
        if (!is_array($documents)) {
30
            return [$documents];
31
        }
32
33
        return $documents;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function transformToIds($entity)
40
    {
41
        $this->validateEntityClass($entity);
42
43
        $ids = $this->handleTransformToIds($entity);
44
45
        if (!is_array($ids)) {
46
            return [$ids];
47
        }
48
49
        return $ids;
50
    }
51
52
    /**
53
     * Implement this method returning either a Document or an array of Document objects.
54
     *
55
     * You do not need to check the class of $entity as this is already handled.
56
     *
57
     * @param object $entity
58
     * @return Document[]|Document
59
     */
60
    abstract protected function handleTransformToDocuments($entity);
61
62
    /**
63
     * Implement this method returning either a single id or an array of ids.
64
     *
65
     * You do not need to check the class of $entity as this is already handled.
66
     *
67
     * @param object $entity
68
     * @return string|int|string[]|int[]
69
     */
70
    abstract protected function handleTransformToIds($entity);
71
}
72