Passed
Push — master ( 7ec3d6...1eec8f )
by Johnny
02:22
created

Trigger::getTopic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
/*
3
 * This file is part of Rivescript-php
4
 *
5
 * (c) Shea Lewis <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Axiom\Rivescript\Cortex;
12
13
use Axiom\Collections\Collection;
14
use Axiom\Rivescript\Cortex\ResponseQueue\ResponseQueue;
15
16
/**
17
 * Trigger class
18
 *
19
 * This class contains information about
20
 * a Trigger itself.
21
 *
22
 * PHP version 7.4 and higher.
23
 *
24
 * @category Core
25
 * @package  Cortext\Commands
26
 * @author   Johnny Mast <[email protected]>
27
 * @license  https://opensource.org/licenses/MIT MIT
28
 * @link     https://github.com/axiom-labs/rivescript-php
29
 * @since    0.4.0
30
 */
31
class Trigger
32
{
33
    /**
34
     * The text for the trigger.
35
     *
36
     * @var string
37
     */
38
    public string $text = '';
39
40
    public string $topic = '';
41
42
    public string $type = '';
43
44
    public int $order = 0;
45
46
    public ResponseQueue $queue;
47
48
    public string $redirect = '';
49
50
51
    /**
52
     * @param string                                               $text
53
     * @param string                                               $topic
54
     * @param string                                               $type
55
     * @param \Axiom\Rivescript\Cortex\ResponseQueue\ResponseQueue $responses
56
     */
57
    public function __construct(string $text, string $topic, string $type, ResponseQueue $queue)
58
    {
59
        $this->text = $text;
60
        $this->topic = $topic;
61
        $this->type = $type;
62
        $this->queue = $queue;
63
    }
64
65
    public function hasResponses(): bool
66
    {
67
        return ($this->getQueue()->getAttachedResponses()->count() > 0);
68
    }
69
70
    public function getQueue(): Collection
71
    {
72
        return $this->queue;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getText(): string
79
    {
80
        return $this->text;
81
    }
82
83
    public function getTopic(): string
84
    {
85
        return $this->topic;
86
    }
87
88
    public function setRedirect(string $redirect)
89
    {
90
        $this->redirect = $redirect;
91
    }
92
93
    public function getRedirect(): string
94
    {
95
        return $this->redirect;
96
    }
97
98
    public function getType(): string
99
    {
100
        return $this->type;
101
    }
102
103
    public function getOrder(): int
104
    {
105
        return $this->order;
106
    }
107
108
    public function setOrder(int $order = 0): void
109
    {
110
        $this->order = $order;
111
    }
112
}
113