Completed
Push — ezp_30981_content_info_proxy ( 6fc040...a78a98 )
by
unknown
15:33
created

ProxyDomainMapperFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 4 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Repository\ProxyFactory;
10
11
use eZ\Publish\API\Repository\Repository;
12
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, eZ\Publish\Core\Reposito...adingValueHolderFactory.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
13
14
/**
15
 * @internal
16
 */
17
final class ProxyDomainMapperFactory
18
{
19
    /** @var \ProxyManager\Factory\LazyLoadingValueHolderFactory */
20
    private $lazyLoadingValueHolderFactory;
21
22
    public function __construct(LazyLoadingValueHolderFactory $lazyLoadingValueHolderFactory)
23
    {
24
        $this->lazyLoadingValueHolderFactory = $lazyLoadingValueHolderFactory;
25
    }
26
27
    public function create(Repository $repository): ProxyDomainMapperInterface
28
    {
29
        return new ProxyDomainMapper($repository, $this->lazyLoadingValueHolderFactory);
30
    }
31
}
32