Test Failed
Push — master ( dc15ab...6abe5f )
by Szymon
01:26
created

BookProjection::project()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Book\Projection;
6
7
use App\Domain\Book\Event\BookWasCreated;
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
class BookProjection implements ReadModelProjection
12
{
13
    public function project(ReadModelProjector $projector): ReadModelProjector
14
    {
15
        $projector->fromStream('event_stream')
16
            ->when([
17
                BookWasCreated::class => function ($state, BookWasCreated $event) {
18
                    /** @var BookReadModel $readModel */
19
                    $readModel = $this->readModel();
20
                    $readModel->stack('insert', [
0 ignored issues
show
Bug introduced by
The method stack() does not exist on App\Infrastructure\Book\Projection\BookReadModel. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
                    $readModel->/** @scrutinizer ignore-call */ 
21
                                stack('insert', [

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
                        'id' => $event->userId()->toString(),
22
                        'name' => $event->name()->toString(),
23
                        'email' => $event->emailAddress()->toString(),
24
                    ]);
25
                },
26
            ]);
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...
27
    }
28
}
29