ViewBench::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Psi\Component\ContentType\Benchmark;
4
5
use Psi\Component\ContentType\Standard\View\ObjectType;
6
use Psi\Component\ContentType\Tests\Functional\BaseTestCase;
7
use Psi\Component\ContentType\Tests\Functional\Example\Model\Article;
8
use Psi\Component\ContentType\Tests\Functional\Example\Model\Image;
9
10
/**
11
 * @BeforeMethods({"setUp"})
12
 * @Revs(500)
13
 * @Iterations(10)
14
 * @OutputTimeUnit("milliseconds", precision=2)
15
 */
16
class ViewBench extends BaseTestCase
17
{
18
    private $factory;
19
20
    public function setUp()
21
    {
22
        $container = $this->getContainer([
23
            'mapping' => [
24
                Article::class => [
25
                    'fields' => [
26
                        'title' => [
27
                            'type' => 'text',
28
                        ],
29
                        'image' => [
30
                            'type' => 'image',
31
                        ],
32
                    ],
33
                ],
34
            ],
35
        ]);
36
        $this->factory = $container->get('psi_content_type.view.factory');
37
    }
38
39
    /**
40
     * @Subject()
41
     */
42 View Code Duplication
    public function create_object_view()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $article = new Article();
45
        $article->title = 'Hello';
46
        $article->image = new Image('/path/to/image.jpg', 100, 100, 'image/jpeg');
47
        $this->factory->create(ObjectType::class, $article, []);
48
    }
49
50
    /**
51
     * @Subject()
52
     */
53 View Code Duplication
    public function create_object_view_and_iterate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $article = new Article();
56
        $article->title = 'Hello';
57
        $article->image = new Image('/path/to/image.jpg', 100, 100, 'image/jpeg');
58
        $view = $this->factory->create(ObjectType::class, $article, []);
59
        iterator_to_array($view);
60
    }
61
}
62