Passed
Push — dev ( 20f168...3a8ec2 )
by Nico
15:39
created

getCurrentUserDepositMinings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2.003

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 1
dl 0
loc 18
ccs 10
cts 11
cp 0.9091
crap 2.003
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Repository;
6
7
use Doctrine\ORM\EntityRepository;
8
use Override;
0 ignored issues
show
Bug introduced by
The type Override 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 Stu\Orm\Entity\ColonyDepositMining;
10
use Stu\Orm\Entity\ColonyDepositMiningInterface;
11
use Stu\Orm\Entity\ColonyInterface;
12
13
/**
14
 * @extends EntityRepository<ColonyDepositMining>
15
 */
16
final class ColonyDepositMiningRepository extends EntityRepository implements ColonyDepositMiningRepositoryInterface
17
{
18
    #[Override]
19
    public function prototype(): ColonyDepositMiningInterface
20
    {
21
        return new ColonyDepositMining();
22
    }
23
24
    #[Override]
25
    public function save(ColonyDepositMiningInterface $entity): void
26
    {
27
        $em = $this->getEntityManager();
28
29
        $em->persist($entity);
30
    }
31
32 5
    #[Override]
33
    public function getCurrentUserDepositMinings(ColonyInterface $colony): array
34
    {
35 5
        $result = [];
36
37
        foreach (
38 5
            $this->findBy(
39 5
                [
40 5
                    'user' => $colony->getUser(),
41 5
                    'colony' => $colony
42 5
                ],
43 5
                ['commodity_id' => 'ASC']
44 5
            ) as $deposit
45
        ) {
46
            $result[$deposit->getCommodity()->getId()] = $deposit;
47
        }
48
49 5
        return $result;
50
    }
51
}
52