Passed
Pull Request — master (#85)
by
unknown
03:54
created

VariantImagePathResolver::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitBag\SyliusWishlistPlugin\Resolver;
6
7
use Sylius\Component\Core\Model\ProductVariantInterface;
8
9
final class VariantImagePathResolver implements VariantImagePathResolverInterface
10
{
11
    public function resolve(ProductVariantInterface $variant, string $baseUrl)
12
    {
13
        $imagePath = $variant->getProduct()->getImages()->first()->getPath();
0 ignored issues
show
Bug introduced by
The method getImages() does not exist on Sylius\Component\Product\Model\ProductInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Product\Model\Product. Are you sure you never get one of those? ( Ignorable by Annotation )

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

13
        $imagePath = $variant->getProduct()->/** @scrutinizer ignore-call */ getImages()->first()->getPath();
Loading history...
14
        return $baseUrl.'/media/image/'.$imagePath;
15
    }
16
}