Lines 76.92% 10 / 13
Functions and Methods 50.00% 2 / 4
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Permission 76.92% 10 / 13 50.00% 2 / 4 5.31 0.00% 0 / 1
 getEntityMapping 100.00% 5 / 5 100.00% 1 / 1 1
 addOrderByName 100.00% 2 / 2 100.00% 1 / 1 1
 addConditionName 0.00% 0 / 2 0.00% 0 / 1 2
 addConditionNames 75.00% 3 / 4 0.00% 0 / 1 2.06
1<?php
2
3namespace BO\Zmsbackend\Permission\Repository;
4
5class Permission extends \BO\Zmsbackend\Query\Base implements \BO\Zmsbackend\Query\MappingInterface
6{
7    /**
8     * @var string TABLE mysql table reference
9     */
10    const string TABLE = 'permission';
11
12    /**
13     * @return string[]
14     *
15     */
16    #[\Override]
17    public function getEntityMapping()
18    {
19        return [
20            'id' => 'permission.id',
21            'name' => 'permission.name',
22            'description' => 'permission.description',
23        ];
24    }
25
26    public function addOrderByName(string $order = 'ASC'): self
27    {
28        $this->query->orderBy('permission.name', $order);
29        return $this;
30    }
31
32    /** @psalm-api */
33    public function addConditionName(string $name): self
34    {
35        $this->query->where('permission.name', '=', $name);
36        return $this;
37    }
38
39    public function addConditionNames(array $names): self
40    {
41        if ($names === []) {
42            throw new \InvalidArgumentException('Argument $names must not be empty.');
43        }
44        $this->query->whereIn('permission.name', $names);
45        return $this;
46    }
47}