Passed
Push — master ( 61b2f8...584670 )
by Chubarov
05:03
created

GetMessageRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setMessageId() 0 3 1
A getXml() 0 3 1
A isCompleted() 0 3 1
A setClient() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Fns\GetMessage\Request;
5
6
use Fns\ClientSoap;
7
use Fns\Contracts\ResponseSendMessage;
8
9
abstract class GetMessageRequest
10
{
11
    private $messageId;
12
    protected $client;
13
14
    const PROCESSING = 'PROCESSING';
15
    const COMPLETED = 'COMPLETED';
16
17
    /**
18
     * Check response status is Completed
19
     * @param $response
20
     * @return bool
21
     */
22
    protected function isCompleted($response) : bool
23
    {
24
        return $response->ProcessingStatus === self::COMPLETED;
25
    }
26
27
    /**
28
     * Return array xml with parameter MessageId
29
     * @return array
30
     */
31
    protected function getXml() : array
32
    {
33
        return [['MessageId' => $this->messageId]];
34
    }
35
36
    /**
37
     * @param string $messageId
38
     */
39
    public function setMessageId(string $messageId): void
40
    {
41
        $this->messageId = $messageId;
42
    }
43
44
    public function setClient(ClientSoap $clientSoap)
45
    {
46
        $this->client = $clientSoap->getClient();
47
    }
48
49
    abstract public function send();
50
51
    /**
52
     * Get message type:CheckTicket or GetTicket
53
     * @return string
54
     */
55
    abstract public function getTypeMessage() : string;
56
57
    /**
58
     * Get class child SimpleXMLElement for handler response
59
     * @return string
60
     */
61
    abstract public function getXmlResponseClass() : string;
62
63
    abstract public function getResponse() : ResponseSendMessage;
64
}
65