summaryrefslogtreecommitdiff
path: root/src/RequestMessage.php
blob: 46dfba3df56e99c82ce31dbb866e552be0c4cac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace jobd;

class RequestMessage extends Message {

    protected $requestType;
    protected $requestData;
    protected $password;

    /**
     * Request constructor.
     * @param string $request_type
     * @param null $request_data
     */
    public function __construct(string $request_type, $request_data = null) {
        parent::__construct(Message::REQUEST);

        $this->requestData = $request_data;
        $this->requestType = $request_type;
    }

    /**
     * @param string $password
     */
    public function setPassword(string $password) {
        $this->password = $password;
    }

    /**
     * @return string[]
     */
    public function getContent(): array {
        $request = ['type' => $this->requestType];
        if (!is_null($this->requestData))
            $request['data'] = $this->requestData;
        return $request;
    }

}