Completed
Push — master ( e7b929...ba2691 )
by Dmitry
03:11
created

Job   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 10
c 3
b 0
f 2
lcom 1
cbo 1
dl 0
loc 54
ccs 0
cts 40
cp 0
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A dispatch() 0 4 1
A fire() 0 4 1
A get() 0 4 1
A find() 0 4 1
A __construct() 0 4 1
A findOrCreate() 0 4 1
A findOne() 0 4 1
A findOrFail() 0 4 1
A remove() 0 4 1
1
<?php
2
3
namespace Basis;
4
5
use Tarantool\Mapper\{Mapper, Entity};
6
7
abstract class Job
8
{
9
    private $app;
10
11
    public function __construct(Application $app)
12
    {
13
        $this->app = $app;
14
    }
15
16
    public function create(string $space, array $data) : Entity
17
    {
18
        return $this->get(Mapper::class)->create($space, $data);
19
    }
20
21
    public function dispatch(string $job, array $params = [])
22
    {
23
        return $this->app->dispatch($job, $params);
24
    }
25
26
    public function fire(string $event, array $context)
27
    {
28
        return $this->get(Event::class)->fire($event, $context);
29
    }
30
31
    public function get(string $class)
32
    {
33
        return $this->app->get($class);
34
    }
35
36
    public function find(string $space, array $params = []) : array
37
    {
38
        return $this->get(Mapper::class)->find($space, $params);
39
    }
40
41
    public function findOrCreate(string $space, array $params = []) : Entity
42
    {
43
        return $this->get(Mapper::class)->findOrCreate($space, $params);
44
    }
45
46
    public function findOne(string $space, array $params = []) : ?Entity
47
    {
48
        return $this->get(Mapper::class)->findOne($space, $params);
49
    }
50
51
    public function findOrFail(string $space, array $params = []) : Entity
52
    {
53
        return $this->get(Mapper::class)->findOrFail($space, $params);
54
    }
55
56
    public function remove(string $space, array $params = [])
57
    {
58
        return $this->get(Mapper::class)->remove($space, $params);
59
    }
60
}
61