FlowManager::deleteStep()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Traits;
4
5
use Hechoenlaravel\JarvisFoundation\Flows\DeleteFlowCommand;
6
use Hechoenlaravel\JarvisFoundation\Flows\DeleteStepCommand;
7
use Hechoenlaravel\JarvisFoundation\Flows\DeleteTransitionCommand;
8
use Hechoenlaravel\JarvisFoundation\Flows\Handler\DeleteFlowCommandHandler;
9
use Hechoenlaravel\JarvisFoundation\Flows\Handler\DeleteStepCommandHandler;
10
use Hechoenlaravel\JarvisFoundation\Flows\Handler\DeleteTransitionCommandHandler;
11
use Hechoenlaravel\JarvisFoundation\Flows\Step;
12
use Hechoenlaravel\JarvisFoundation\Flows\Flow;
13
use Hechoenlaravel\JarvisFoundation\Flows\EditFlowCommand;
14
use Hechoenlaravel\JarvisFoundation\Flows\EditStepCommand;
15
use Hechoenlaravel\JarvisFoundation\Flows\CreateFlowCommand;
16
use Hechoenlaravel\JarvisFoundation\Flows\CreateStepCommand;
17
use Hechoenlaravel\JarvisFoundation\Flows\CreateTransitionCommand;
18
use Hechoenlaravel\JarvisFoundation\Flows\Middleware\SetStepOrder;
19
use Hechoenlaravel\JarvisFoundation\Flows\Handler\EditFlowCommandHandler;
20
use Hechoenlaravel\JarvisFoundation\Flows\Handler\EditStepCommandHandler;
21
use Hechoenlaravel\JarvisFoundation\Flows\Handler\CreateFlowCommandHandler;
22
use Hechoenlaravel\JarvisFoundation\Flows\Handler\CreateStepCommandHandler;
23
use Hechoenlaravel\JarvisFoundation\Flows\Handler\CreateTransitionCommandHandler;
24
use Hechoenlaravel\JarvisFoundation\Flows\Transition;
25
26
/**
27
 * Class FlowManager
28
 * @package Hechoenlaravel\JarvisFoundation\Traits
29
 */
30
trait FlowManager
31
{
32
    use DispatchesCommands;
33
34
    /**
35
     * @param array $data
36
     * @return mixed
37
     */
38
    public function createFlow(array $data)
39
    {
40
        return $this->execute(CreateFlowCommand::class, CreateFlowCommandHandler::class, $data);
41
    }
42
43
    /**
44
     * @param Flow $flow
45
     * @param array $data
46
     * @return mixed
47
     */
48
    public function updateFlow(Flow $flow, array $data)
49
    {
50
        return $this->execute(EditFlowCommand::class, EditFlowCommandHandler::class, array_merge(['flow' => $flow], $data));
51
    }
52
53
    /**
54
     * @param Flow $flow
55
     * @return mixed
56
     */
57
    public function deleteFlow(Flow $flow)
58
    {
59
        return $this->execute(DeleteFlowCommand::class, DeleteFlowCommandHandler::class, ['flow' => $flow]);
60
    }
61
62
    /**
63
     * @param array $data
64
     * @return mixed
65
     */
66
    public function createStep(array $data)
67
    {
68
        return $this->execute(CreateStepCommand::class, CreateStepCommandHandler::class, $data, [SetStepOrder::class]);
69
    }
70
71
    /**
72
     * @param Step $step
73
     * @param array $data
74
     * @return mixed
75
     */
76
    public function updateStep(Step $step, array $data)
77
    {
78
        return $this->execute(EditStepCommand::class, EditStepCommandHandler::class, array_merge(['step' => $step], $data));
79
    }
80
81
    /**
82
     * @param Step $step
83
     * @return mixed
84
     */
85
    public function deleteStep(Step $step)
86
    {
87
        return $this->execute(DeleteStepCommand::class, DeleteStepCommandHandler::class, ['step' => $step]);
88
    }
89
90
    /**
91
     * @param array $data
92
     * @return mixed
93
     */
94
    public function createTransition(array $data)
95
    {
96
        return $this->execute(CreateTransitionCommand::class, CreateTransitionCommandHandler::class, $data, []);
97
    }
98
99
    /**
100
     * @param Transition $transition
101
     * @return mixed
102
     */
103
    public function deleteTransition(Transition $transition)
104
    {
105
        return $this->execute(DeleteTransitionCommand::class, DeleteTransitionCommandHandler::class, ['transition' => $transition], []);
106
    }
107
}
108