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

PatronEnableRequest::getMessageString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
ccs 0
cts 9
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
 * PatronEnableRequest can be used by the SC to re-enable canceled patrons. It should only be used for system testing
7
 * and validation. The ACS should respond with a Patron Enable Response message.
8
 *
9
 * @method setInstitutionId(string $institutionId)
10
 * @method setPatronIdentifier(string $patron)
11
 * @method setTerminalPassword(string $terminalPassword)
12
 * @method setPatronPassword(string $patronPassword)
13
 *
14
 * @licence    https://opensource.org/licenses/MIT
15
 * @copyright  John Wohlers <[email protected]>
16
 * @copyright  Paul Dixon <[email protected]>
17
 */
18
class PatronEnableRequest extends SIP2Request
19
{
20
    protected $var = [
21
        'InstitutionId' => [],
22
        'PatronIdentifier' => [],
23
        'TerminalPassword' => ['default' => ''],
24
        'PatronPassword' => ['default' => ''],
25
    ];
26
27
    public function getMessageString($withSeq = true, $withCrc = true): string
28
    {
29
        $this->newMessage('25');
30
        $this->addFixedOption($this->datestamp(), 18);
31
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
32
        $this->addVarOption('AA', $this->getVariable('PatronIdentifier'));
33
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'), true);
34
        $this->addVarOption('AD', $this->getVariable('PatronPassword'), true);
35
36
        return $this->returnMessage($withSeq, $withCrc);
37
    }
38
}
39