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

HoldResponse   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 20
dl 0
loc 47
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 1
1
<?php
2
3
namespace lordelph\SIP2\Response;
4
5
/**
6
 * Class HoldResponse provides the response from a HoldRequest
7
 *
8
 * @method getOk()
9
 * @method getAvailable()
10
 * @method getTransactionDate()
11
 * @method getExpirationDate()
12
 * @method getQueuePosition()
13
 * @method getPickupLocation()
14
 * @method getInstitutionId()
15
 * @method getPatronIdentifier()
16
 * @method getItemIdentifier()
17
 * @method getTitleIdentifier()
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 HoldResponse extends SIP2Response
27
{
28
    //fixed part of response contains these
29
    protected $var = [
30
        'Ok' => [],
31
        'Available' => [],
32
        'TransactionDate' => []
33
    ];
34
35
    //variable part of the response allowed to contain these...
36
    protected $allowedVariables=[
37
        self::BW_EXPIRATION_DATE,
38
        self::BR_QUEUE_POSITION,
39
        self::BS_PICKUP_LOCATION,
40
        self::AO_INSTITUTION_ID,
41
        self::AA_PATRON_IDENTIFIER,
42
        self::AB_ITEM_IDENTIFIER,
43
        self::AJ_TITLE_IDENTIFIER,
44
        self::AF_SCREEN_MESSAGE,
45
        self::AG_PRINT_LINE,
46
        self::AY_SEQUENCE_NUMBER
47
    ];
48
49
    public function __construct($raw)
50
    {
51
        /*
52
         *   $result = [];
53
        $result['fixed'] =
54
            [
55
                'Ok' => substr($response, 2, 1),
56
                'available' => substr($response, 3, 1),
57
                'TransactionDate' => substr($response, 4, 18)
58
            ];
59
60
        //expiration date is optional an indicated by BW
61
        $variableOffset = 22;
62
        if (substr($response, 22, 2) === 'BW') {
63
            $result['fixed']['ExpirationDate'] = substr($response, 24, 18);
64
            $variableOffset = 42;
65
        }
66
67
        $result['variable'] = $this->parseVariableData($response, $variableOffset);
68
         */
69
        $this->setVariable('Ok', substr($raw, 2, 1));
70
        $this->setVariable('Available', substr($raw, 3, 1));
71
        $this->setVariable('TransactionDate', substr($raw, 4, 18));
72
        $this->parseVariableData($raw, 22);
73
    }
74
}
75