Issues (21)

src/SendMessageRequest.php (3 issues)

1
<?php
2
declare(strict_types=1);
3
4
namespace Fns;
5
6
use Fns\Contracts\ResponseSendMessage;
7
use Fns\GetMessage\Request\GetMessageRequest;
8
9
class SendMessageRequest
10
{
11
    private $ticket;
12
13
    /**
14
     * @var ClientSoap
15
     */
16
    private $client;
17
    /**
18
     * @var GetMessageRequest
19
     */
20
    private $messageRequest;
21
    private $server;
0 ignored issues
show
The private property $server is not used, and could be removed.
Loading history...
22
23
    public function __construct(
24
        ClientSoap $clientSoap,
25
        GetMessageRequest $messageRequest
26
    ) {
27
        $this->client = $clientSoap->getClient();
0 ignored issues
show
Documentation Bug introduced by
It seems like $clientSoap->getClient() of type SoapClient is incompatible with the declared type Fns\ClientSoap of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
29
        $this->messageRequest = $messageRequest;
30
        $this->messageRequest->setClient($clientSoap);
31
    }
32
33
    protected function getXml() : array
34
    {
35
        $type = $this->messageRequest->getTypeMessage();
36
37
        return [[
38
            'Message' => [
39
                'any' => "<{$type}Request xmlns=\"urn://x-artefacts-gnivc-ru/ais3/kkt/KktTicketService/types/1.0\"
40
                    xmlns:tns=\"urn://x-artefacts-gnivc-ru/ais3/kkt/KktTicketService/types/1.0\">
41
                        <tns:{$type}Info>
42
                                {$this->ticket->asXml()}
43
                        </tns:{$type}Info>
44
                    </{$type}Request>"
45
            ]
46
        ]];
47
    }
48
49
    public function setTicket(Ticket $ticket)
50
    {
51
        $this->ticket = $ticket;
52
    }
53
54
    public function execute() : ResponseSendMessage
55
    {
56
        $messageId = $this->client->__soapCall('SendMessage', $this->getXml())->MessageId;
0 ignored issues
show
The method __soapCall() does not exist on Fns\ClientSoap. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
        $messageId = $this->client->/** @scrutinizer ignore-call */ __soapCall('SendMessage', $this->getXml())->MessageId;

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58
        $this->messageRequest->setMessageId($messageId);
59
        $this->messageRequest->send();
60
        return $this->messageRequest->getResponse();
61
    }
62
}
63