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

CheckInRequest::getMessageString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 14
ccs 0
cts 13
cp 0
rs 9.9
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
 * CheckInRequest is used by the SC to request to check in an item, and also to cancel a Checkout request that did not
7
 * successfully complete. The ACS must respond to this command with a Checkin Response message.
8
 *
9
 * You must call setItemIdentifier() to provide the barcode of the item you're checking in. Other variables
10
 * are optional or set automatically by the SIP2Client
11
 *
12
 * @method setNoBlock(string $yn)
13
 * @method setItemReturnDate(string $timestamp)
14
 * @method setItemLocation(string $location)
15
 * @method setInstitutionId(string $institutionId)
16
 * @method setItemIdentifier(string $itemIdentifier)
17
 * @method setTerminalPassword(string $terminalPassword)
18
 * @method setItemProperties(string $itemProperties)
19
 * @method setCancel(string $yn)
20
 *
21
 * @licence    https://opensource.org/licenses/MIT
22
 * @copyright  John Wohlers <[email protected]>
23
 * @copyright  Paul Dixon <[email protected]>
24
 */
25
class CheckInRequest extends SIP2Request
26
{
27
    protected $var = [
28
        'NoBlock' => ['type' => 'YN', 'default' => 'N'],
29
        'ItemReturnDate' => ['type' => 'timestamp', 'default' => ''],
30
        'ItemLocation' => ['default' => ''],
31
        'InstitutionId' => [],
32
        'ItemIdentifier' => [],
33
        'TerminalPassword' => ['default' => ''],
34
        'ItemProperties' => ['default' => ''],
35
        'Cancel' => ['type' => 'YN', 'default' => 'N'],
36
    ];
37
38
    public function getMessageString($withSeq = true, $withCrc = true): string
39
    {
40
        $this->newMessage('09');
41
        $this->addFixedOption($this->getVariable('NoBlock'), 1);
42
        $this->addFixedOption($this->datestamp(), 18);
43
        $this->addFixedOption($this->getVariable('ItemReturnDate'), 18);
44
        $this->addVarOption('AP', $this->getVariable('ItemLocation'));
45
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
46
        $this->addVarOption('AB', $this->getVariable('ItemIdentifier'));
47
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'));
48
        $this->addVarOption('CH', $this->getVariable('ItemProperties'), true);
49
        $this->addVarOption('BI', $this->getVariable('Cancel'), true);
50
51
        return $this->returnMessage($withSeq, $withCrc);
52
    }
53
}
54