These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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
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 |
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.