Passed
Push — master ( 0b2fa8...ba5181 )
by Anton
07:25 queued 12s
created

Service::fire()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
nc 1
nop 3
dl 0
loc 8
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
/**
4
 * @copyright Bluz PHP Team
5
 * @link https://github.com/bluzphp/skeleton
6
 */
7
8
declare(strict_types=1);
9
10
namespace Application\Events;
11
12
/**
13
 * Class Service
14
 *
15
 * @package Application\Events
16
 */
17
class Service
18
{
19
    /**
20
     * Set option value for use it from any application place
21
     *
22
     * @param string $event
23
     * @param string $target
24
     * @param array $data
25
     * @return mixed
26
     * @throws \Bluz\Db\Exception\DbException
27
     * @throws \Bluz\Db\Exception\InvalidPrimaryKeyException
28
     * @throws \Bluz\Db\Exception\TableNotFoundException
29
     */
30
    public static function fire(string $event, string $target, array $data = [])
31
    {
32
        /** @var Row $row */
33
        $row = Table::create();
34
        $row->event = $event;
35
        $row->target = $target;
36
        $row->data = json_encode($data);
37
        return $row->save();
38
    }
39
}
40