Issues (256)

StatementForwarding/StatementForwardingHandler.php (6 issues)

1
<?php
2
3
namespace Ijeffro\Laralocker\LearningLocker\StatementForwarding;
4
5
use Ijeffro\Laralocker\LearningLocker\API\APIHandler;
6
7
class StatementForwardingHandler extends APIHandler {
8
9
    private $statement_forwarding = '/statementforwarding';
10
    private $api = '/api';
11
    private $v1 = '/v1';
0 ignored issues
show
The private property $v1 is not used, and could be removed.
Loading history...
12
    private $v2 = '/v2';
13
14
    protected $headers = [
15
      'Content-Type' => 'application/json'
16
    ];
17
18
    function __construct($id = null) {
19
        parent::__construct();
20
        $this->id = $id;
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
    }
22
23
24
    /**
25
     * Learning Locker: Request Organisation Details
26
     *
27
     * @return  $response
0 ignored issues
show
Documentation Bug introduced by
The doc comment $response at position 0 could not be parsed: Unknown type name '$response' at position 0 in $response.
Loading history...
28
     */
29
    public function get() {
30
        try {
31
            $url = $this->url . $this->api . $this->v2 . $this->statement_forwarding . '/' . $this->id ?? $this->id;
32
            $response = $this->request($url);
33
            return $response;
34
        } catch (Exception $e) {
0 ignored issues
show
The type Ijeffro\Laralocker\Learn...entForwarding\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
35
            return $e;
36
        }
37
    }
38
39
    /**
40
     * Learning Locker: Request Organisation Details
41
     *
42
     * @return  $response
0 ignored issues
show
Documentation Bug introduced by
The doc comment $response at position 0 could not be parsed: Unknown type name '$response' at position 0 in $response.
Loading history...
43
     */
44
    public function update($data) {
45
        try {
46
            $url = $this->url . $this->api . $this->v2 . $this->statement_forwarding . '/' . $this->id ?? $this->id;
47
            $response = $this->save($url, $data);
48
            return $response;
49
        } catch (Exception $e) {
50
            return $e;
51
        }
52
    }
53
54
    /**
55
     * Learning Locker: Request Organisation Details
56
     *
57
     * @return  $response
0 ignored issues
show
Documentation Bug introduced by
The doc comment $response at position 0 could not be parsed: Unknown type name '$response' at position 0 in $response.
Loading history...
58
     */
59
    public function create($data = null) {
60
        try {
61
            $url = $this->url . $this->api . $this->v2 . $this->statement_forwarding;
62
            $response = $this->make($url, $data);
63
            return $response;
64
        } catch (Exception $e) {
65
            return $e;
66
        }
67
    }
68
}
69