CheckInRequest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMessageString() 0 14 1
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 1
    public function getMessageString($withSeq = true, $withCrc = true): string
39
    {
40 1
        $this->newMessage('09');
41 1
        $this->addFixedOption($this->getVariable('NoBlock'), 1);
42 1
        $this->addFixedOption($this->datestamp(), 18);
43 1
        $this->addFixedOption($this->getVariable('ItemReturnDate'), 18);
44 1
        $this->addVarOption('AP', $this->getVariable('ItemLocation'));
45 1
        $this->addVarOption('AO', $this->getVariable('InstitutionId'));
46 1
        $this->addVarOption('AB', $this->getVariable('ItemIdentifier'));
47 1
        $this->addVarOption('AC', $this->getVariable('TerminalPassword'));
48 1
        $this->addVarOption('CH', $this->getVariable('ItemProperties'), true);
49 1
        $this->addVarOption('BI', $this->getVariable('Cancel'), true);
50
51 1
        return $this->returnMessage($withSeq, $withCrc);
52
    }
53
}
54