MediaService
last analyzed

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 46

4 Methods

Rating   Name   Duplication   Size   Complexity  
getProductMediaList() 0 1 ?
getVariantMediaList() 0 1 ?
getProductsMedia() 0 1 ?
getProductMedia() 0 1 ?
1
<?php
2
/**
3
 * (c) shopware AG <[email protected]>
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace ShopwarePlugins\Connect\Components;
9
10
use Shopware\Bundle\StoreFrontBundle\Struct;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, ShopwarePlugins\Connect\Components\Struct.

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...
11
12
interface MediaService
13
{
14
    /**
15
     * Wrapper method of Shopware Core ProductMediaGateway
16
     *
17
     * @see \Shopware\Bundle\StoreFrontBundle\Gateway\ProductMediaGatewayInterface::getList()
18
     *
19
     * @param Struct\BaseProduct[] $products
20
     * @param Struct\ShopContextInterface $context
21
     * @return array Indexed by the product order number. Each element contains a \Shopware\Bundle\StoreFrontBundle\Struct\Media array.
22
     */
23
    public function getProductMediaList(array $products, Struct\ShopContextInterface $context);
24
25
    /**
26
     * Wrapper method of Shopware Core VariantMediaGateway
27
     *
28
     * @see \Shopware\Bundle\StoreFrontBundle\Gateway\VariantMediaGatewayInterface::getList()
29
     *
30
     * @param Struct\BaseProduct[] $products
31
     * @param Struct\ShopContextInterface $context
32
     * @return array Indexed by product number. Each element contains a \Shopware\Bundle\StoreFrontBundle\Struct\Media array.
33
     */
34
    public function getVariantMediaList(array $products, Struct\ShopContextInterface $context);
35
36
    /**
37
     * Wrapper method of Shopware Core MediaService
38
     *
39
     * @see \Shopware\Bundle\StoreFrontBundle\Service\Core\MediaService::getProductsMedia()
40
     *
41
     * @param Struct\BaseProduct[] $products
42
     * @param Struct\ShopContextInterface $context
43
     * @return Struct\Media[]
44
     */
45
    public function getProductsMedia($products, Struct\ShopContextInterface $context);
46
47
    /**
48
     * Wrapper method of Shopware Core MediaService
49
     *
50
     * @see \Shopware\Bundle\StoreFrontBundle\Service\Core\MediaService::getProductMedia()
51
     *
52
     * @param Struct\BaseProduct $product
53
     * @param Struct\ShopContextInterface $context
54
     * @return Struct\Media[]
55
     */
56
    public function getProductMedia($product, Struct\ShopContextInterface $context);
57
}
58