Issues (256)

src/LearningLocker/Client/Client.php (1 issue)

1
<?php
2
namespace HT2\Integrations\LearningLocker;
3
4
use HT2\Integrations\LearningLocker\Connection;
0 ignored issues
show
The type HT2\Integrations\LearningLocker\Connection 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...
5
use Exception;
6
7
class Client extends Connection {
8
  
9
  private $client = '/client';
10
  private $api = '/api';
11
  private $v2 = '/v2';
12
  
13
  private $headers = [
14
    'content-type' => 'application/json'
15
  ];
16
17
18
  public function check() {
19
    try {
20
      $request = $this->get();
21
    } catch (Exception $e) {
22
      return false;
23
    }
24
    return true;
25
  }
26
27
  public function get() {
28
    $url = $this->endpoint . $this->api . $this->v2 . $this->client . '/';
29
    $request = $this->getClient()->get($url, [
30
      'auth' => $this->getAuth(),
31
      'headers' => [
32
        'content-type' => 'application/json'
33
      ],
34
    ]);
35
36
    if($request->getStatusCode() === 404) {
37
      throw new Exception('There was a issue connecting to Learning Locker.');
38
    }
39
40
    $response = $request->json();
41
42
    return true;
43
  }
44
}
45