Completed
Push — master ( 03cde8...21f90a )
by Paul
02:45
created

PatronStatusResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace lordelph\SIP2\Response;
4
5
/**
6
 * Class PatronStatusResponse provides the response from a PatronStatusRequest and a BlockPatronRequest
7
 *
8
 * @method getPatronStatus()
9
 * @method getLanguage()
10
 * @method getTransactionDate()
11
 * @method getInstitutionId()
12
 * @method getPatronIdentifier()
13
 * @method getPersonalName()
14
 * @method getValidPatron()
15
 * @method getValidPatronPassword()
16
 * @method getFeeAmount()
17
 * @method getCurrencyType()
18
 * @method getScreenMessage()
19
 * @method getPrintLine()
20
 * @method getSequenceNumber()
21
 *
22
 * @licence    https://opensource.org/licenses/MIT
23
 * @copyright  John Wohlers <[email protected]>
24
 * @copyright  Paul Dixon <[email protected]>
25
 */
26
class PatronStatusResponse extends SIP2Response
27
{
28
    //fixed part of response contains these
29
    protected $var = [
30
        'PatronStatus' => [],
31
        'Language' => [],
32
        'TransactionDate' => []
33
    ];
34
35
    //variable part of the response allowed to contain these...
36
    protected $allowedVariables=[
37
        self::AO_INSTITUTION_ID,
38
        self::AA_PATRON_IDENTIFIER,
39
        self::AE_PERSONAL_NAME,
40
        self::BL_VALID_PATRON,
41
        self::CQ_VALID_PATRON_PASSWORD,
42
        self::BH_CURRENCY_TYPE,
43
        self::BV_FEE_AMOUNT,
44
        self::AF_SCREEN_MESSAGE,
45
        self::AG_PRINT_LINE,
46
        self::AY_SEQUENCE_NUMBER
47
    ];
48
49
    public function __construct($raw)
50
    {
51
        $this->setVariable('PatronStatus', substr($raw, 2, 14));
52
        $this->setVariable('Language', substr($raw, 16, 3));
53
        $this->setVariable('TransactionDate', substr($raw, 19, 18));
54
55
        $this->parseVariableData($raw, 37);
56
    }
57
}
58