JourneyHandler   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 37
c 1
b 0
f 0
dl 0
loc 88
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
A update() 0 7 2
A progress() 0 6 4
A create() 0 7 2
A __construct() 0 3 1
A delete() 0 7 2
1
<?php
2
3
namespace Ijeffro\Laralocker\LearningLocker\Journeys;
4
5
use Ijeffro\Laralocker\LearningLocker\API\APIHandler;
6
use Ijeffro\Laralocker\LearningLocker\JourneyProgress\JourneyProgressHandler;
7
8
class JourneyHandler extends APIHandler {
9
10
    private $journey = '/journey';
11
    private $api = '/api';
12
    private $v1 = '/v1';
0 ignored issues
show
introduced by
The private property $v1 is not used, and could be removed.
Loading history...
13
    private $v2 = '/v2';
14
15
    public $journey_progress;
16
17
    protected $headers = [
18
      'Content-Type' => 'application/json'
19
    ];
20
21
    function __construct($id = null) {
22
        parent::__construct();
23
        $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...
24
    }
25
26
    /**
27
     * Learning Locker API: Clients
28
     *
29
     * @return ClientHandler
0 ignored issues
show
Bug introduced by
The type Ijeffro\Laralocker\Learn...\Journeys\ClientHandler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
     */
31
    public function progress($id = null)
32
    {
33
        if ($this->journey_progress) return $this->journey_progress;
34
35
        $this->journey_progress = new JourneyProgressHandler($id ? $id : null);
36
        return $this->progress($id ? $id : null);
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 get() {
45
        try {
46
            $url = $this->url . $this->api . $this->v2 . $this->journey;
47
            $response = $this->request($url);
48
            return $response;
49
        } catch (Exception $e) {
0 ignored issues
show
Bug introduced by
The type Ijeffro\Laralocker\Learn...cker\Journeys\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
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 update($data) {
60
        try {
61
            $url = $this->url . $this->api . $this->v2 . $this->journey . '/' . $this->id ?? $this->id;
62
            $response = $this->save($url, $data);
63
            return $response;
64
        } catch (Exception $e) {
65
            return $e;
66
        }
67
    }
68
69
    /**
70
     * Learning Locker: Request Organisation Details
71
     *
72
     * @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...
73
     */
74
    public function delete() {
75
        try {
76
            $url = $this->url . $this->api . $this->v2 . $this->journey . '/' . $this->id;
77
            $response = $this->destroy($url);
78
            return $response;
79
        } catch (Exception $e) {
80
            return $e;
81
        }
82
    }
83
84
    /**
85
     * Learning Locker: Request Organisation Details
86
     *
87
     * @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...
88
     */
89
    public function create($data = null) {
90
        try {
91
            $url = $this->url . $this->api . $this->v2 . $this->journey;
92
            $response = $this->make($url, $data);
93
            return $response;
94
        } catch (Exception $e) {
95
            return $e;
96
        }
97
    }
98
99
}
100