Completed
Push — develop ( 4bf430...c74260 )
by
unknown
18:30
created

SearchForm::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Controller\Plugin;
12
13
use Core\Form\TextSearchForm;
14
use Zend\Form\FormElementManager;
15
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
16
17
/**
18
 * Fetches a text search form.
19
 * 
20
 * @author Mathias Gelhausen <[email protected]>
21
 * @since 0.25
22
 */
23
class SearchForm extends AbstractPlugin
24
{
25
26
    /**
27
     * The form element manager.
28
     *
29
     * @var \Zend\Form\FormElementManager
30
     */
31
    protected $formElementManager;
32
33
    /**
34
     * Creates an instance.
35
     *
36
     * @param FormElementManager $forms
37
     */
38
    public function __construct(FormElementManager $forms)
39
    {
40
        $this->formElementManager = $forms;
41
    }
42
43
    /**
44
     * Direct invokation.
45
     *
46
     * Proxies to {@link get()}
47
     *
48
     * @param string|array     $elementsFieldset
0 ignored issues
show
Bug introduced by
There is no parameter named $elementsFieldset. 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...
49
     * @param null|string $buttonsFieldset
0 ignored issues
show
Bug introduced by
There is no parameter named $buttonsFieldset. 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...
50
     *
51
     * @return \Core\Form\TextSearchForm
0 ignored issues
show
Documentation introduced by
Should the return type not be \Core\Form\SearchForm?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
52
     */
53
    public function __invoke($form, $options = null)
54
    {
55
        return $this->get($form, $options);
56
    }
57
58
    /**
59
     * Fetches a text search form.
60
     *
61
     * If only the service for an element fieldset ist passed,
62
     * it will fetch a "Core/TextSearch" form and pass the
63
     * elements fieldset along.
64
     *
65
     * @param string|array     $form
66
     *
67
     * @return \Core\Form\SearchForm
68
     */
69
    public function get($form, $options = null)
70
    {
71
        if (!is_object($form)) {
72
            $form             = $this->formElementManager->get($form, $options);
73
        }
74
75
        /** @noinspection PhpUndefinedMethodInspection */
76
        $params           = $this->getController()->getRequest()->getQuery()->toArray();
77
78
        $form->setSearchParams($params);
79
        return $form;
80
    }
81
}