CloudRendererTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 9
dl 0
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRender() 0 46 1
1
<?php
2
3
namespace SixtyNine\Cloud\Tests\Renderer;
4
5
use Imagine\Gd\Image;
6
use SixtyNine\Cloud\Builder\CloudBuilder;
7
use SixtyNine\Cloud\Builder\FiltersBuilder;
8
use SixtyNine\Cloud\Builder\PalettesBuilder;
9
use SixtyNine\Cloud\Builder\WordsListBuilder;
10
use SixtyNine\Cloud\Color\RandomColorGenerator;
11
use SixtyNine\Cloud\Factory\FontsFactory;
12
use SixtyNine\Cloud\Factory\PlacerFactory;
13
use SixtyNine\Cloud\Renderer\CloudRenderer;
14
use PHPUnit\Framework\TestCase;
15
16
class CloudRendererTest extends TestCase
17
{
18
    public function testRender()
19
    {
20
        $colorGenerator = new RandomColorGenerator(PalettesBuilder::create()->getRandomPalette());
21
22
        $list = WordsListBuilder::create()
23
            ->randomizeOrientation(50)
24
            ->randomizeColors($colorGenerator)
25
            ->importWords(<<<EOF
26
Algorithms to detect collision in 2D games depend on the type of shapes that can collide (e.g. Rectangle to Rectangle,
27
Rectangle to Circle, Circle to Circle). Generally you will have a simple generic shape that covers the entity known as
28
a "hitbox" so even though collision may not be pixel perfect, it will look good enough and be performant across multiple
29
entities. This article provides a review of the most common techniques used to provide collision detection in 2D games.
30
EOF
31
            )
32
            ->setFilters(FiltersBuilder::create()
33
                ->setMinLength(5)
34
                ->setMaxLength(10)
35
                ->build()
36
            )
37
//            ->setMaxWords(30)
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
            ->build('foobar')
39
        ;
40
41
        $factory = FontsFactory::create(__DIR__ . '/../fixtures/fonts');
42
43
        $placerName = PlacerFactory::PLACER_CIRCULAR;
44
        $placer = PlacerFactory::getInstance()->getPlacer($placerName, 800, 600);
45
46
        $cloud = CloudBuilder::create($factory)
47
            ->setBackgroundColor('#ffffff')
48
            ->setDimension(800, 600)
49
            ->setFont('Arial.ttf')
50
            ->setPlacer($placerName)
51
            ->useList($list)
52
            ->build()
53
        ;
54
55
        $renderer = new CloudRenderer($cloud, $factory);
56
        $renderer->renderCloud();
57
        $image = $renderer->getImage();
58
        $renderer->renderUsher($placer, '#FFAA50');
59
60
        $this->assertInstanceOf(Image::class, $image);
61
62
//        $image->save('/tmp/image.png');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
    }
64
}
65