Completed
Push — master ( 0330ad...fd62a8 )
by Filipe
03:14
created

SelectEventTriggers::triggerBeforeSelect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 14
loc 14
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 2
crap 1
1
<?php
2
3
/**
4
 * This file is part of slick/orm package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Orm\Repository\QueryObject;
11
12
use Slick\Database\RecordList;
13
use Slick\Database\Sql\Select;
14
use Slick\Orm\Descriptor\EntityDescriptorInterface;
15
use Slick\Orm\Entity\EntityCollection;
16
use Slick\Orm\Mapper\EventTriggers;
17
use Slick\Orm\Orm;
18
19
/**
20
 * Select Event Trigger methods
21
 *
22
 * @package Slick\Orm\Repository\QueryObject
23
 * @author  Filipe Silva <[email protected]>
24
 */
25
trait SelectEventTriggers
26
{
27
28
    /**
29
     * Use event triggers
30
     */
31
    use EventTriggers;
32
33
    /**
34
     * Emit before select event
35
     *
36
     * @param Select $query
37
     * @param EntityDescriptorInterface $entityDescriptor
38
     *
39
     * @return \League\Event\EventInterface|string
40
     */
41 2 View Code Duplication
    public function triggerBeforeSelect(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
        Select $query, EntityDescriptorInterface $entityDescriptor
43
    ) {
44 2
        $event = new \Slick\Orm\Event\Select(
45 2
            null,
46
            [
47 2
                'query' => $query,
48 1
                'entityDescriptor' => $entityDescriptor
49 1
            ]
50 1
        );
51 2
        $event->setAction(\Slick\Orm\Event\Select::ACTION_BEFORE_SELECT);
52 2
        return Orm::getEmitter($this->getEntityClassName())
53 2
            ->emit($event);
54
    }
55
56
    /**
57
     * Emits the after select event
58
     *
59
     * @param RecordList $data
60
     * @param EntityCollection $entity
0 ignored issues
show
Bug introduced by
There is no parameter named $entity. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
61
     *
62
     * @return \League\Event\EventInterface|string
63
     */
64 2 View Code Duplication
    public function triggerAfterSelect($data, EntityCollection $entities)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66 2
        $event = new \Slick\Orm\Event\Select(
67 2
            null,
68
            [
69 2
                'data' => $data,
70 1
                'entityCollection' => $entities
71 1
            ]
72 1
        );
73 2
        $event->setAction(\Slick\Orm\Event\Select::ACTION_AFTER_SELECT);
74 2
        return Orm::getEmitter($this->getEntityClassName())
75 2
            ->emit($event);
76
    }
77
78
79
}