Passed
Push — develop ( 53b14c...3240e8 )
by Johnny
03:29 queued 01:41
created

Previous::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
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\Contracts\Response as ResponseContract;
14
15
/**
16
 * ContinueResponse class
17
 *
18
 * The Previous class determines if the response type
19
 * is a previous type.
20
 *
21
 * PHP version 7.4 and higher.
22
 *
23
 * @category Core
24
 * @package  Cortext\Responses
25
 * @author   Johnny Mast <[email protected]>
26
 * @license  https://opensource.org/licenses/MIT MIT
27
 * @link     https://github.com/axiom-labs/rivescript-php
28
 * @since    0.4.0
29
 */
30
class Previous extends Response implements ResponseContract
31
{
32
33
    /**
34
     * Handle Continue responses.
35
     *
36
     * @return false|string
37
     */
38
    public function parse()
39
    {
40
        if ($this->responseQueueItem()->getCommand() === '%') {
41
            return $this->source();
42
        }
43
44
        return false;
45
    }
46
47
    /**
48
     * Indicate the type of response this
49
     * class handles.
50
     *
51
     * @return string
52
     */
53
    public function getType(): string
54
    {
55
        return 'previous';
56
    }
57
}
58