Mapbox   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 70
ccs 12
cts 13
cp 0.9231
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tilesets() 0 3 1
A uploads() 0 3 1
A __construct() 0 3 1
A features() 0 7 2
A datasets() 0 3 1
1
<?php
2
3
namespace Bakerkretzmar\LaravelMapbox;
4
5
use RunTimeException;
6
7
class Mapbox
8
{
9
    /**
10
     * Mapbox API endpoint names and status codes.
11
     */
12
    const DATASETS_ENDPOINT = 'datasets';
13
    const TILESETS_ENDPOINT = 'tilesets';
14
    const FEATURES_ENDPOINT = 'features';
15
    const UPLOADS_ENDPOINT = 'uploads';
16
    const DELETE_SUCCESS_STATUS = 204;
17
18
    protected $config;
19
20
    /**
21
     * Create a new instance of the Mapbox API wrapper.
22
     *
23
     * @param  array  $config
24
     */
25 36
    public function __construct(array $config = [])
26
    {
27 36
        $this->config = $config;
28 36
    }
29
30
    /**
31
     * Create a new Datasets request.
32
     *
33
     * @param   string|null  $dataset_id
34
     * @return  Datasets
35
     */
36 30
    public function datasets(string $dataset_id = null)
37
    {
38 30
        return new Datasets($dataset_id);
39
    }
40
41
    /**
42
     * Shortcut to create a new Features request for a given Dataset.
43
     *
44
     * @param   string       $dataset_id
45
     * @param   string|null  $feature_id
46
     * @return  Features
47
     */
48 10
    public function features(string $dataset_id, string $feature_id = null)
49
    {
50 10
        if (! $dataset_id) {
51
            throw new RunTimeException('Dataset ID required');
52
        }
53
54 10
        return new Features($dataset_id, $feature_id);
55
    }
56
57
    /**
58
     * Create a new Tilesets request.
59
     *
60
     * @param   string|null  $tileset_id
61
     * @return  Tilesets
62
     */
63 14
    public function tilesets(string $tileset_id = null)
64
    {
65 14
        return new Tilesets($tileset_id);
66
    }
67
68
    /**
69
     * Create a new Uploads request.
70
     *
71
     * @param   string|null  $upload_id
72
     * @return  Uploads
73
     */
74 12
    public function uploads(string $upload_id = null)
75
    {
76 12
        return new Uploads($upload_id);
77
    }
78
}
79