Passed
Push — master ( 635254...1bd0f2 )
by Johnny
02:00
created

Response::source()   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
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/*
3
 * This file is part of Rivescript-php
4
 *
5
 * (c) Johnny Mast <[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\Responses;
12
13
use Axiom\Rivescript\Cortex\ResponseQueue\ResponseQueueItem;
14
use Axiom\Rivescript\Traits\Regex;
15
16
/**
17
 * Response class
18
 *
19
 * The Response class is a base class for all response types in this
20
 * directory, it contains some helpful functions.
21
 *
22
 * PHP version 7.4 and higher.
23
 *
24
 * @category Core
25
 * @package  Cortext\Responses
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
abstract class Response
32
{
33
    use Regex;
34
35
    /**
36
     * @var ResponseQueueItem
37
     */
38
    protected ResponseQueueItem $responseQueueItem;
39
40
    /**
41
     * @var string
42
     */
43
    protected string $source = '';
44
45
    /**
46
     * @var string
47
     */
48
    protected string $original = "";
49
50
    /**
51
     * Responses must implement this method to
52
     * indicate the response type.
53
     *
54
     * @return string
55
     */
56
    abstract public function getType(): string;
57
58
    /**
59
     * Response constructor.
60
     *
61
     * @param string            $source            The response line.
62
     * @param ResponseQueueItem $responseQueueItem Queue information about the response line.
63
     */
64
    public function __construct(string $source, ResponseQueueItem $responseQueueItem)
65
    {
66
        $this->source = $source;
67
        $this->original = $this->source;
68
        $this->responseQueueItem = $responseQueueItem;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function source(): string
75
    {
76
        return $this->source;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function original(): string
83
    {
84
        return $this->original;
85
    }
86
87
    /**
88
     * Return the responseQueueItem.
89
     *
90
     * @return ResponseQueueItem
91
     */
92
    public function responseQueueItem(): ResponseQueueItem
93
    {
94
        return $this->responseQueueItem;
95
    }
96
}
97