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

BlockPatronRequest::getMessageString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace lordelph\SIP2\Request;
4
5
/**
6
 * BlockPatronRequest requests that the patron card be blocked by the ACS. This is, for example, sent when the patron
7
 * is detected tampering with the SC or when a patron forgets to take their card. The ACS should invalidate the
8
 * patron’s card and respond with a Patron Status Response message. The ACS could also notify the library staff
9
 * that the card has been blocked.
10
 *
11
 * @method setCardRetained(string $yn)
12
 * @method setInstitutionId(string $institutionId)
13
 * @method setMessage(string $message)
14
 * @method setPatronIdentifier(string $patron)
15
 * @method setTerminalPassword(string $terminalPassword)
16
 *
17
 * @licence    https://opensource.org/licenses/MIT
18
 * @copyright  John Wohlers <[email protected]>
19
 * @copyright  Paul Dixon <[email protected]>
20
 */
21
class BlockPatronRequest extends SIP2Request
22
{
23
    protected $var = [
24
        'CardRetained' => ['type' => 'YN', 'default' => 'N'],
25
        'InstitutionId' => [],
26
        'Message' => ['default' => ''],
27
        'PatronIdentifier' => [],
28
        'TerminalPassword' => ['default' => ''],
29
    ];
30
31
    public function getMessageString($withSeq = true, $withCrc = true): string
32
    {
33
        $this->newMessage('01');
34
        $this->addFixedOption($this->getVariable('CardRetained'), 1);
35
        $this->addFixedOption($this->datestamp(), 18);
36
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
37
        $this->addVarOption('AL', $this->getVariable('Message'));
38
        $this->addVarOption('AA', $this->getVariable('PatronIdentifier'));
39
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'));
40
41
        return $this->returnMessage($withSeq, $withCrc);
42
    }
43
}
44