Conditions | 4 |
Paths | 5 |
Total Lines | 45 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function indexAction(Request $request) |
||
19 | { |
||
20 | $term = $request->get('term'); |
||
21 | $form = $this->createForm( |
||
22 | SearchType::class, |
||
23 | array('term' => $term) |
||
24 | ); |
||
25 | |||
26 | $form->handleRequest($request); |
||
27 | |||
28 | if ($form->isValid()) { |
||
29 | $data = $form->getData(); |
||
30 | |||
31 | return $this->redirect( |
||
32 | $this->generateUrl( |
||
33 | 'sumocoders_frameworksearch_default_index', |
||
34 | array( |
||
35 | 'term' => $data['term'] |
||
36 | ) |
||
37 | ) |
||
38 | ); |
||
39 | } |
||
40 | |||
41 | $results = null; |
||
42 | if ('' != $term) { |
||
43 | $repository = $this->getDoctrine()->getRepository('SumoCodersFrameworkSearchBundle:IndexItem'); |
||
44 | $dispatcher = $this->get('event_dispatcher'); |
||
45 | $search = new Search($repository, $dispatcher, $term); |
||
|
|||
46 | |||
47 | $results = $search->search(); |
||
48 | } |
||
49 | |||
50 | if ('' != $term) { |
||
51 | $this->get('framework.breadcrumb_builder') |
||
52 | ->addSimpleItem( |
||
53 | $term |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | return array( |
||
58 | 'term' => $term, |
||
59 | 'form' => $form->createView(), |
||
60 | 'results' => $results, |
||
61 | ); |
||
62 | } |
||
63 | } |
||
64 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.