Completed
Push — master ( d1ea0c...72efe0 )
by Dmitry
03:12
created

Toolkit::findOrFail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
crap 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Basis;
4
use Tarantool\Mapper\Mapper;
5
use Tarantool\Mapper\Entity;
6
7
trait Toolkit
8
{
9
    protected $app;
10
11 1
    public function create(string $space, array $data) : Entity
12
    {
13 1
        return $this->get(Mapper::class)->create($space, $data);
14
    }
15
16 2
    public function dispatch(string $job, array $params = [], string $service = null)
17
    {
18 2
        return $this->app->dispatch($job, $params, $service);
19
    }
20
21 1
    public function find(string $space, $params = []) : array
22
    {
23 1
        return $this->get(Mapper::class)->find($space, $params);
24
    }
25
26 1
    public function findOne(string $space, $params = []) : ?Entity
27
    {
28 1
        return $this->get(Mapper::class)->findOne($space, $params);
29
    }
30
31 1
    public function findOrCreate(string $space, $params = []) : Entity
32
    {
33 1
        return $this->get(Mapper::class)->findOrCreate($space, $params);
34
    }
35
36 1
    public function findOrFail(string $space, $params = []) : Entity
37
    {
38 1
        return $this->get(Mapper::class)->findOrFail($space, $params);
39
    }
40
41
    public function fire(string $event, array $context)
42
    {
43
        return $this->get(Event::class)->fire($event, $context);
44
    }
45
46 1
    public function get(string $class)
47
    {
48 1
        return $this->app->get($class);
49
    }
50
51 1
    public function remove(string $space, array $params = [])
52
    {
53 1
        return $this->get(Mapper::class)->remove($space, $params);
54
    }
55
56
    public function __debugInfo()
57
    {
58
        $info = get_object_vars($this);
59
        unset($info['app']);
60
        return $info;
61
    }
62
}
63