Test Failed
Push — master ( 9fbc6a...43929d )
by Eugene
03:16
created

ActionSearchJpg::getQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace App\Actions\Image;
3
4
use SearchManager\Manager as SearchManager;
5
use Staticus\Auth\UserInterface;
6
use Staticus\Middlewares\ActionSearchAbstract;
7
use Staticus\Resources\Image\ResourceImageDOInterface;
8
9
class ActionSearchJpg extends ActionSearchAbstract
10
{
11
12
    public function __construct(
13
        ResourceImageDOInterface $resourceDO
14
        , SearchManager $manager
15
        , UserInterface $user
16
    )
17
    {
18
        parent::__construct($resourceDO, $manager, $user);
0 ignored issues
show
Unused Code introduced by
The call to ActionSearchAbstract::__construct() has too many arguments starting with $user.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
19
        $this->user = $user;
0 ignored issues
show
Bug introduced by
The property user does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
    }
21
22
    /**
23
     * @return \SearchManager\Image\SearchImageDTO
24
     */
25
    protected function search()
26
    {
27
        /** @var SearchManager $searcher */
28
        $searcher = $this->searcher;
29
        $query = $this->getQuery();
30
        $cursor = $this->getCursor();
0 ignored issues
show
Bug introduced by
The method getCursor() does not seem to exist on object<App\Actions\Image\ActionSearchJpg>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
32
        return $searcher->generate($query, $cursor);
0 ignored issues
show
Unused Code introduced by
The call to Manager::generate() has too many arguments starting with $cursor.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    protected function getQuery()
39
    {
40
        return $this->resourceDO->getName() . ' ' . $this->resourceDO->getNameAlternative();
41
    }
42
}