summaryrefslogtreecommitdiff
path: root/src/RequestMessage.php
blob: 85b978697e40e4fa9e88d59f59619f3f6f11db07 (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[]
     */
    protected function getContent(): array {
        $request = ['type' => $this->requestType];
        if (!is_null($this->requestData))
            $request['data'] = $this->requestData;
        return $request;
    }

}