TestPlugin::onStart()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
use Yosymfony\Spress\Core\DataSource\Item;
4
use Yosymfony\Spress\Core\DataSource\Memory\MemoryDataSource;
5
use Yosymfony\Spress\Core\Plugin\PluginInterface;
6
use Yosymfony\Spress\Core\Plugin\EventSubscriber;
7
use Yosymfony\Spress\Core\Plugin\Event\EnvironmentEvent;
8
use Yosymfony\Spress\Core\Plugin\Event\ContentEvent;
9
use Yosymfony\Spress\Core\Plugin\Event\FinishEvent;
10
use Yosymfony\Spress\Core\Plugin\Event\RenderEvent;
11
12
class TestPlugin implements PluginInterface
13
{
14
    public function getMetas()
15
    {
16
        return [
17
            'name' => 'Test plugin',
18
        ];
19
    }
20
21
    public function initialize(EventSubscriber $subscriber)
22
    {
23
        $subscriber->addEventListener('spress.start', 'onStart');
0 ignored issues
show
Documentation introduced by
'onStart' is of type string, but the function expects a object<Closure>.

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...
24
        $subscriber->addEventListener('spress.before_convert', 'onBeforeConvert');
0 ignored issues
show
Documentation introduced by
'onBeforeConvert' is of type string, but the function expects a object<Closure>.

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...
25
        $subscriber->addEventListener('spress.after_convert', 'onAfterConvert');
0 ignored issues
show
Documentation introduced by
'onAfterConvert' is of type string, but the function expects a object<Closure>.

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...
26
        $subscriber->addEventListener('spress.before_render_blocks', 'onBeforeRenderBlocks');
0 ignored issues
show
Documentation introduced by
'onBeforeRenderBlocks' is of type string, but the function expects a object<Closure>.

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...
27
        $subscriber->addEventListener('spress.after_render_blocks', 'onAfterRenderBlocks');
0 ignored issues
show
Documentation introduced by
'onAfterRenderBlocks' is of type string, but the function expects a object<Closure>.

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
        $subscriber->addEventListener('spress.before_render_page', 'onBeforeRenderPage');
0 ignored issues
show
Documentation introduced by
'onBeforeRenderPage' is of type string, but the function expects a object<Closure>.

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...
29
        $subscriber->addEventListener('spress.after_render_page', 'onAfterRenderPage');
0 ignored issues
show
Documentation introduced by
'onAfterRenderPage' is of type string, but the function expects a object<Closure>.

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...
30
        $subscriber->addEventListener('spress.finish', 'onFinish');
0 ignored issues
show
Documentation introduced by
'onFinish' is of type string, but the function expects a object<Closure>.

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...
31
    }
32
33
    public function onStart(EnvironmentEvent $event)
34
    {
35
        $dsm = $event->getDataSourceManager();
36
37
        $item = new Item('Content from item in memory data source', 'memory-datasource.txt');
38
        $item->setPath('memory-datasource.txt', Item::SNAPSHOT_PATH_RELATIVE);
39
40
        $memoryDataSource = new MemoryDataSource();
41
        $memoryDataSource->addItem($item);
42
43
        $dsm->setDataSource('memory-plugin', $memoryDataSource);
44
    }
45
46
    public function onBeforeConvert(ContentEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
47
    {
48
    }
49
50
    public function onAfterConvert(ContentEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
51
    {
52
    }
53
54
    public function onBeforeRenderBlocks(RenderEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
55
    {
56
    }
57
58
    public function onAfterRenderBlocks(RenderEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
59
    {
60
    }
61
62
    public function onBeforeRenderPage(RenderEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
63
    {
64
    }
65
66
    public function onAfterRenderPage(RenderEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
67
    {
68
    }
69
70
    public function onFinish(FinishEvent $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

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

Loading history...
71
    {
72
    }
73
}
74