FactoryBench::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Psi\Component\Description\Benchmarks\Micro;
4
5
use Psi\Component\Description\Tests\Functional\Example\FooEnhancer;
6
use Psi\Component\Description\DescriptionFactory;
7
use Psi\Component\Description\Schema\Extension\StandardExtension;
8
use Psi\Component\Description\Tests\Functional\Example\Foo;
9
use Psi\Component\Description\Subject;
10
use Psi\Component\Description\Schema\Schema;
11
use Psi\Component\Description\Schema\Extension\HierarchyExtension;
12
13
/**
14
 * @BeforeMethods({"setUp"})
15
 * @Revs(1000)
16
 * @Iterations(10)
17
 */
18
class FactoryBench
19
{
20
    private $factory;
21
    private $validatedFactory;
22
23
    public function setUp()
24
    {
25
        $this->factory = new DescriptionFactory([
26
            new FooEnhancer(),
27
        ], []);
0 ignored issues
show
Documentation introduced by
array() is of type array, but the function expects a null|object<Psi\Componen...cription\Schema\Schema>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
28
29
        $schema = new Schema([
30
            new StandardExtension(),
31
            new HierarchyExtension(),
32
        ]);
33
34
        $this->validatedFactory = new DescriptionFactory([
35
            new FooEnhancer(),
36
        ], [], $schema);
0 ignored issues
show
Documentation introduced by
array() is of type array, but the function expects a null|object<Psi\Componen...cription\Schema\Schema>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$schema is of type object<Psi\Component\Description\Schema\Schema>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
    }
38
39
    public function benchFactory()
40
    {
41
        $foo = new Foo();
42
        $foo->title = 'Hello World';
43
44
        $this->factory->describe(Subject::createFromObject($foo));
45
    }
46
47
    public function benchValidatedFactory()
48
    {
49
        $foo = new Foo();
50
        $foo->title = 'Hello World';
51
52
        $this->validatedFactory->describe(Subject::createFromObject($foo));
53
    }
54
}
55