Product::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File: Product.php
6
 *
7
 * @author      Maciej Sławik <[email protected]>
8
 * Github:      https://github.com/maciejslawik
9
 */
10
11
namespace MSlwk\CatalogMode\Plugin\Catalog\Model;
12
13
use Magento\Catalog\Model\Product as ProductModel;
14
use MSlwk\CatalogMode\Api\CatalogModeConfigProviderInterface;
15
16
/**
17
 * Class Product
18
 * @package MSlwk\CatalogMode\Plugin\Catalog\Model
19
 */
20
class Product
21
{
22
    /**
23
     * @var CatalogModeConfigProviderInterface
24
     */
25
    private $catalogModeConfigProvider;
26
27
    /**
28
     * Product constructor.
29
     * @param CatalogModeConfigProviderInterface $catalogModeConfigProvider
30
     */
31
    public function __construct(CatalogModeConfigProviderInterface $catalogModeConfigProvider)
32
    {
33
        $this->catalogModeConfigProvider = $catalogModeConfigProvider;
34
    }
35
36
    /**
37
     * @param ProductModel $subject
38
     * @param bool $result
39
     * @return bool
40
     */
41
    public function afterIsSalable(ProductModel $subject, bool $result)
0 ignored issues
show
Unused Code introduced by
The parameter $subject is not used and could be removed.

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

Loading history...
42
    {
43
        return $this->catalogModeConfigProvider->isCatalogMode() ? false : $result;
44
    }
45
46
    /**
47
     * @param ProductModel $subject
48
     * @param bool $result
49
     * @return bool
50
     */
51
    public function afterGetIsSalable(ProductModel $subject, bool $result)
0 ignored issues
show
Unused Code introduced by
The parameter $subject is not used and could be removed.

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

Loading history...
52
    {
53
        return $this->catalogModeConfigProvider->isCatalogMode() ? false : $result;
54
    }
55
}
56