CheckOutRequest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 27
c 1
b 0
f 0
dl 0
loc 34
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMessageString() 0 18 1
1
<?php
2
3
namespace lordelph\SIP2\Request;
4
5
/**
6
 * CheckOutRequest is used by the SC to request to check out an item, and also to cancel a CheckIn request that did
7
 * not successfully complete. The ACS must respond to this command with a CheckOut Response message.
8
 *
9
 * You must call setItemIdentifier() to provide the barcode of the item you're checking out. Other variables
10
 * are optional or set automatically by the SIP2Client
11
 *
12
 * @method setSCRenewal(string $yn)
13
 * @method setNoBlock(string $yn)
14
 * @method setNBDateDue(string $timestamp)
15
 * @method setInstitutionId(string $institutionId)
16
 * @method setPatronIdentifier(string $patron)
17
 * @method setItemIdentifier(string $itemIdentifier)
18
 * @method setTerminalPassword(string $terminalPassword)
19
 * @method setItemProperties(string $itemProperties)
20
 * @method setPatronPassword(string $patronPassword)
21
 * @method setFeeAcknowledged(string $yn)
22
 * @method setCancel(string $yn)
23
 *
24
 * @licence    https://opensource.org/licenses/MIT
25
 * @copyright  John Wohlers <[email protected]>
26
 * @copyright  Paul Dixon <[email protected]>
27
 */
28
class CheckOutRequest extends SIP2Request
29
{
30
    protected $var = [
31
        'SCRenewal' => ['type' => 'YUN', 'default' => 'N'],
32
        'NoBlock' => ['type' => 'YN', 'default' => 'N'],
33
        'NBDateDue' => ['type' => 'timestamp', 'default' => ''],
34
        'InstitutionId' => [],
35
        'PatronIdentifier' => [],
36
        'ItemIdentifier' => [],
37
        'TerminalPassword' => ['default' => ''],
38
        'ItemProperties' => ['default' => ''],
39
        'PatronPassword' => ['default' => ''],
40
        'FeeAcknowledged' => ['type' => 'YN', 'default' => 'N'],
41
        'Cancel' => ['type' => 'YN', 'default' => 'N'],
42
    ];
43
44 1
    public function getMessageString($withSeq = true, $withCrc = true): string
45
    {
46 1
        $this->newMessage('11');
47 1
        $this->addFixedOption($this->getVariable('SCRenewal'), 1);
48 1
        $this->addFixedOption($this->getVariable('NoBlock'), 1);
49 1
        $this->addFixedOption($this->datestamp(), 18);
50 1
        $this->addFixedOption($this->getVariable('NBDateDue'), 18);
51
52 1
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
53 1
        $this->addVarOption('AA', $this->getVariable('PatronIdentifier'));
54 1
        $this->addVarOption('AB', $this->getVariable('ItemIdentifier'));
55 1
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'));
56 1
        $this->addVarOption('CH', $this->getVariable('ItemProperties'), true);
57 1
        $this->addVarOption('AD', $this->getVariable('PatronPassword'), true);
58 1
        $this->addVarOption('BO', $this->getVariable('FeeAcknowledged'), true);
59 1
        $this->addVarOption('BI', $this->getVariable('Cancel'), true);
60
61 1
        return $this->returnMessage($withSeq, $withCrc);
62
    }
63
}
64