MoveJsToFooter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\DeferJs\Plugin;
11
12
use Closure;
13
use Hryvinskyi\DeferJs\Helper\Config;
14
use Hryvinskyi\DeferJs\Model\MoveJsToFooterInterface;
15
use Magento\Framework\App\Request\Http as RequestHttp;
16
use Magento\Framework\App\Response\Http;
17
use Magento\Framework\Controller\ResultInterface;
18
19
/**
20
 * Class MoveJsToFooter
21
 */
22
class MoveJsToFooter
23
{
24
    /**
25
     * Configuration Module
26
     *
27
     * @var Config
28
     */
29
    private $config;
30
31
    /**
32
     * Request HTTP
33
     *
34
     * @var RequestHttp
35
     */
36
    private $request;
37
38
    /**
39
     * Mover Js
40
     *
41
     * @var MoveJsToFooterInterface
42
     */
43
    private $moveJsToFooter;
44
45
    /**
46
     * MoveJsToFooter constructor.
47
     *
48
     * @param Config $config
49
     * @param RequestHttp $request
50
     * @param MoveJsToFooterInterface $moveJsToFooter
51
     */
52
    public function __construct(
53
        Config $config,
54
        RequestHttp $request,
55
        MoveJsToFooterInterface $moveJsToFooter
56
    ) {
57
        $this->config = $config;
58
        $this->request = $request;
59
        $this->moveJsToFooter = $moveJsToFooter;
60
    }
61
62
    /**
63
     * @param ResultInterface $subject
64
     * @param Closure $proceed
65
     * @param Http $response
66
     *
67
     * @return string
68
     */
69
    public function aroundRenderResult(
70
        ResultInterface $subject,
1 ignored issue
show
Unused Code introduced by
The parameter $subject is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

70
        /** @scrutinizer ignore-unused */ ResultInterface $subject,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
        Closure $proceed,
72
        Http $response
73
    ) {
74
        $result = $proceed($response);
75
76
        if (!$this->config->isEnabled() || PHP_SAPI === 'cli' || $this->request->isXmlHttpRequest()) {
77
            return $result;
78
        }
79
80
        $this->moveJsToFooter->execute($response);
81
82
        return $result;
83
    }
84
}