ListProduct::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MagePrince
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the mageprince.com license that is
9
 * available through the world-wide-web at this URL:
10
 * https://mageprince.com/end-user-license-agreement
11
 *
12
 * DISCLAIMER
13
 *
14
 * Do not edit or add to this file if you wish to upgrade this extension to newer
15
 * version in the future.
16
 *
17
 * @category    MagePrince
18
 * @package     Mageprince_BuyNow
19
 * @copyright   Copyright (c) MagePrince (https://mageprince.com/)
20
 * @license     https://mageprince.com/end-user-license-agreement
21
 */
22
23
namespace Mageprince\BuyNow\Block\Product;
24
25
use Magento\Catalog\Block\Product\Context;
0 ignored issues
show
Bug introduced by
The type Magento\Catalog\Block\Product\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
use Magento\Catalog\Block\Product\ProductList\Item\Block;
0 ignored issues
show
Bug introduced by
The type Magento\Catalog\Block\Pr...\ProductList\Item\Block was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
use Magento\Framework\App\ActionInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\ActionInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use Magento\Framework\Url\Helper\Data as UrlHelper;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Url\Helper\Data was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
30
class ListProduct extends Block
31
{
32
    /**
33
     * @var UrlHelper
34
     */
35
    protected $urlHelper;
36
37
    /**
38
     * ListProduct constructor.
39
     * @param Context $context
40
     * @param UrlHelper $urlHelper
41
     * @param array $data
42
     */
43
    public function __construct(
44
        Context $context,
45
        UrlHelper $urlHelper,
46
        array $data = []
47
    ) {
48
        $this->urlHelper = $urlHelper;
49
        parent::__construct($context, $data);
50
    }
51
52
    /**
53
     * Get post parameters
54
     *
55
     * @param \Magento\Catalog\Model\Product $product
56
     * @return array
57
     */
58
    public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
0 ignored issues
show
Bug introduced by
The type Magento\Catalog\Model\Product was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
59
    {
60
        $url = str_replace(
61
            'checkout/cart/add',
62
            'buynow/cart/add',
63
            $this->getAddToCartUrl($product)
64
        );
65
        return [
66
            'action' => $url,
67
            'data' => [
68
                'product' => $product->getEntityId(),
69
                ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
70
            ]
71
        ];
72
    }
73
}
74