Passed
Pull Request — master (#49)
by Mage
02:28
created

RemoveBuyNowVal::__construct()   A

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
/**
4
 * MagePrince
5
 * Copyright (C) 2020 Mageprince <[email protected]>
6
 *
7
 * @package Mageprince_BuyNow
8
 * @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/)
9
 * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0)
10
 * @author MagePrince <[email protected]>
11
 */
12
13
namespace Mageprince\BuyNow\Observer;
14
15
use Magento\Checkout\Model\Cart as CustomerCart;
0 ignored issues
show
Bug introduced by
The type Magento\Checkout\Model\Cart 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...
16
17
class RemoveBuyNowVal implements \Magento\Framework\Event\ObserverInterface
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Event\ObserverInterface 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...
18
{
19
    /**
20
     * @param \Magento\Quote\Model\QuoteFactory $quoteFactory
21
     * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
22
     * @param CustomerCart $cart
23
     */
24
    public function __construct(
25
        \Magento\Quote\Model\QuoteFactory $quoteFactory,
0 ignored issues
show
Bug introduced by
The type Magento\Quote\Model\QuoteFactory 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
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
0 ignored issues
show
Bug introduced by
The type Magento\Customer\Api\CustomerRepositoryInterface 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
        CustomerCart $cart
28
    ) {
29
        $this->quoteFactory = $quoteFactory;
0 ignored issues
show
Bug Best Practice introduced by
The property quoteFactory does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
        $this->customerRepository = $customerRepository;
0 ignored issues
show
Bug Best Practice introduced by
The property customerRepository does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
        $this->cart = $cart;
0 ignored issues
show
Bug Best Practice introduced by
The property cart does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
32
    }
33
34
    public function execute(\Magento\Framework\Event\Observer $observer)
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Event\Observer 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...
35
    {
36
        if ($this->cart->getQuote()->getItemsCount() > 1) {
37
            $this->cart->getQuote()->setBuyNowId(0);
38
            $this->cart->getQuote()->save();
39
        }
40
    }
41
}
42