RenewRequest::getMessageString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 18
ccs 15
cts 15
cp 1
rs 9.7998
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace lordelph\SIP2\Request;
4
5
/**
6
 * RenewRequest is used to renew an item. The ACS should respond with a Renew Response message.
7
 * Either or both of the setItemIdentifier and setItemTitle methods must be called for the message to
8
 * be useful.
9
 *
10
 * @method setThirdParty(string $yn)
11
 * @method setNoBlock(string $yn)
12
 * @method setNBDateDue(string $timestamp)
13
 * @method setInstitutionId(string $institutionId)
14
 * @method setPatronIdentifier(string $patron)
15
 * @method setPatronPassword(string $patronPassword)
16
 * @method setItemIdentifier(string $itemIdentifier)
17
 * @method setItemTitle(string $itemTitle)
18
 * @method setTerminalPassword(string $terminalPassword)
19
 * @method setItemProperties(string $itemProperties)
20
 * @method setFeeAcknowledged(string $yn)
21
 *
22
 * @licence    https://opensource.org/licenses/MIT
23
 * @copyright  John Wohlers <[email protected]>
24
 * @copyright  Paul Dixon <[email protected]>
25
 */
26
class RenewRequest extends SIP2Request
27
{
28
    protected $var = [
29
        'ThirdParty' => ['type' => 'YN', 'default' => 'N'],
30
        'NoBlock' => ['type' => 'YN', 'default' => 'N'],
31
        'NBDateDue' => ['type' => 'timestamp', 'default' => ''],
32
        'InstitutionId' => [],
33
        'PatronIdentifier' => [],
34
        'PatronPassword' => ['default' => ''],
35
        'ItemIdentifier' => ['default' => ''],
36
        'ItemTitle' => ['default' => ''],
37
        'TerminalPassword' => ['default' => ''],
38
        'ItemProperties' => ['default' => ''],
39
        'FeeAcknowledged' => ['type' => 'YN', 'default' => 'N'],
40
    ];
41
42 1
    public function getMessageString($withSeq = true, $withCrc = true): string
43
    {
44 1
        $this->newMessage('29');
45 1
        $this->addFixedOption($this->getVariable('ThirdParty'), 1);
46 1
        $this->addFixedOption($this->getVariable('NoBlock'), 1);
47 1
        $this->addFixedOption($this->datestamp(), 18);
48 1
        $this->addFixedOption($this->getVariable('NBDateDue'), 18);
49
50 1
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
51 1
        $this->addVarOption('AA', $this->getVariable('PatronIdentifier'));
52 1
        $this->addVarOption('AD', $this->getVariable('PatronPassword'), true);
53 1
        $this->addVarOption('AB', $this->getVariable('ItemIdentifier'), true);
54 1
        $this->addVarOption('AJ', $this->getVariable('ItemTitle'), true);
55 1
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'), true);
56 1
        $this->addVarOption('CH', $this->getVariable('ItemProperties'), true);
57 1
        $this->addVarOption('BO', $this->getVariable('FeeAcknowledged'), true);
58
59 1
        return $this->returnMessage($withSeq, $withCrc);
60
    }
61
}
62