These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Helper\Toolbar; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Helper\AdminRouteHelper; |
||
6 | use Symfony\Component\HttpFoundation\Request; |
||
7 | use Symfony\Component\HttpFoundation\Response; |
||
8 | use Symfony\Component\HttpKernel\DataCollector\DataCollector as BaseDataCollector; |
||
9 | |||
10 | /** |
||
11 | * AbstractDataCollector. |
||
12 | */ |
||
13 | abstract class AbstractDataCollector extends BaseDataCollector implements DataCollectionInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $data = []; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $template; |
||
24 | |||
25 | /** |
||
26 | * @var AdminRouteHelper |
||
27 | */ |
||
28 | protected $adminRouteHelper; |
||
29 | |||
30 | /** |
||
31 | * @return mixed |
||
0 ignored issues
–
show
|
|||
32 | */ |
||
33 | public function getTemplate() |
||
34 | { |
||
35 | return $this->template; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param $template |
||
40 | * |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function setTemplate($template) |
||
44 | { |
||
45 | $this->template = $template; |
||
46 | |||
47 | return $this; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param AdminRouteHelper $adminRouteHelper |
||
52 | */ |
||
53 | public function setAdminRouteHelper(AdminRouteHelper $adminRouteHelper) |
||
54 | { |
||
55 | $this->adminRouteHelper = $adminRouteHelper; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param Request $request |
||
60 | * @param Response $response |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function showDataCollection(Request $request, Response $response) |
||
65 | { |
||
66 | $url = $request->getRequestUri(); |
||
67 | |||
68 | // do not capture redirects or modify XML HTTP Requests |
||
69 | if ($request->isXmlHttpRequest() || $this->adminRouteHelper->isAdminRoute($url) || !$this->isEnabled()) { |
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | View Code Duplication | if ($response->isRedirection() || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) |
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
74 | || 'html' !== $request->getRequestFormat() |
||
75 | || false !== stripos($response->headers->get('Content-Disposition'), 'attachment;') |
||
76 | ) { |
||
77 | return false; |
||
78 | } |
||
79 | |||
80 | return true; |
||
81 | } |
||
82 | } |
||
83 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.