Completed
Push — master ( 2705ab...006cbd )
by Dmitry
04:32
created

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