Response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A responseQueueItem() 0 3 1
A source() 0 3 1
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
     * Responses must implement this method to
47
     * indicate the response type.
48
     *
49
     * @return string
50
     */
51
    abstract public function getType(): string;
52
53
    /**
54
     * Response constructor.
55
     *
56
     * @param string            $source            The response line.
57
     * @param ResponseQueueItem $responseQueueItem Queue information about the response line.
58
     */
59
    public function __construct(string $source, ResponseQueueItem $responseQueueItem)
60
    {
61
        $this->source = $source;
62
        $this->responseQueueItem = $responseQueueItem;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function source(): string
69
    {
70
        return $this->source;
71
    }
72
73
    /**
74
     * Return the responseQueueItem.
75
     *
76
     * @return ResponseQueueItem
77
     */
78
    public function responseQueueItem(): ResponseQueueItem
79
    {
80
        return $this->responseQueueItem;
81
    }
82
}
83