Test Failed
Push — master ( 3df79e...07268c )
by Szymon
02:05
created

CategoryProjection::project()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Category\Projection;
6
7
use App\Domain\Category\Events\CategoryWasCreated;
8
use Prooph\Bundle\EventStore\Projection\ReadModelProjection;
0 ignored issues
show
Bug introduced by
The type Prooph\Bundle\EventStore...ion\ReadModelProjection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Prooph\EventStore\Projection\ReadModelProjector;
0 ignored issues
show
Bug introduced by
The type Prooph\EventStore\Projection\ReadModelProjector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
 * @method readModel()
13
 */
14
class CategoryProjection implements ReadModelProjection
15
{
16
    public function project(ReadModelProjector $projector): ReadModelProjector
17
    {
18
        $projector->fromStream('event_stream')
19
            ->when([
20
                CategoryWasCreated::class => function ($state, CategoryWasCreated $event) {
21
                    /** @var CategoryReadModel $readModel */
22
                    $readModel = $this->readModel();
23
                    $readModel->stack('insert', [
24
                        'id' => $event->getId()->toString(),
25
                        'name' => $event->getName()->toString(),
26
                    ]);
27
                },
28
            ])->run();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Prooph\EventStore\Projection\ReadModelProjector. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
29
    }
30
}
31