Completed
Push — master ( dad5ed...687e58 )
by Igor
15s queued 13s
created

BarcodeAwareExampleFactoryTrait::setBarcodeField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBarcodePlugin\Fixture\Factory;
6
7
use Loevgaard\SyliusBarcodePlugin\Model\BarcodeAwareInterface;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
/**
11
 * It can be used on some custom ProductVariantExampleFactory
12
 * (which Sylius don't have)
13
 */
14
trait BarcodeAwareExampleFactoryTrait
15
{
16
    protected function configureBarcodeOptions(OptionsResolver $resolver, int $chanceOfRandomBarcode = 90): void
0 ignored issues
show
Unused Code introduced by
The parameter $chanceOfRandomBarcode is not used and could be removed. ( Ignorable by Annotation )

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

16
    protected function configureBarcodeOptions(OptionsResolver $resolver, /** @scrutinizer ignore-unused */ int $chanceOfRandomBarcode = 90): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        $resolver
19
            ->setDefault('barcode', static function (): string {
20
                static $faker;
21
22
                if (null === $faker) {
23
                    $faker = \Faker\Factory::create();
24
                }
25
26
                return $faker->ean13;
27
            })
28
            ->setAllowedTypes('barcode', ['null', 'string'])
29
        ;
30
    }
31
32
    protected function setBarcodeField(BarcodeAwareInterface $barcodeAware, array $resolvedOptions = []): void
33
    {
34
        $barcodeAware->setBarcode($resolvedOptions['barcode']);
35
    }
36
}
37