CustomerFixtureRollback::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace TddWizard\Fixtures\Customer;
5
6
use Magento\Customer\Api\CustomerRepositoryInterface;
7
use Magento\Framework\Exception\LocalizedException;
8
use Magento\Framework\Registry;
9
use Magento\TestFramework\Helper\Bootstrap;
0 ignored issues
show
Bug introduced by
The type Magento\TestFramework\Helper\Bootstrap 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...
10
11
/**
12
 * @internal Use CustomerFixture::rollback() or CustomerFixturePool::rollback() instead
13
 */
14
class CustomerFixtureRollback
15
{
16
    /**
17
     * @var Registry
18
     */
19
    private $registry;
20
    /**
21
     * @var CustomerRepositoryInterface
22
     */
23
    private $customerRepository;
24
25 10
    public function __construct(Registry $registry, CustomerRepositoryInterface $customerRepository)
26
    {
27 10
        $this->registry = $registry;
28 10
        $this->customerRepository = $customerRepository;
29 10
    }
30
31 10
    public static function create(): CustomerFixtureRollback
32
    {
33 10
        $objectManager = Bootstrap::getObjectManager();
34 10
        return new self(
35 10
            $objectManager->get(Registry::class),
36 10
            $objectManager->get(CustomerRepositoryInterface::class)
37
        );
38
    }
39
40
    /**
41
     * @param CustomerFixture ...$customerFixtures
42
     * @throws LocalizedException
43
     */
44 10
    public function execute(CustomerFixture ...$customerFixtures): void
45
    {
46 10
        $this->registry->unregister('isSecureArea');
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Registry::unregister() has been deprecated: 102.0.0 ( Ignorable by Annotation )

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

46
        /** @scrutinizer ignore-deprecated */ $this->registry->unregister('isSecureArea');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
47 10
        $this->registry->register('isSecureArea', true);
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Registry::register() has been deprecated: 102.0.0 ( Ignorable by Annotation )

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

47
        /** @scrutinizer ignore-deprecated */ $this->registry->register('isSecureArea', true);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
49 10
        foreach ($customerFixtures as $customerFixture) {
50 10
            $this->customerRepository->deleteById($customerFixture->getId());
51
        }
52
53 10
        $this->registry->unregister('isSecureArea');
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Registry::unregister() has been deprecated: 102.0.0 ( Ignorable by Annotation )

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

53
        /** @scrutinizer ignore-deprecated */ $this->registry->unregister('isSecureArea');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
54 10
    }
55
}
56