Completed
Pull Request — master (#5)
by
unknown
01:14
created

Airtable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Tapp\Airtable;
4
5
class Airtable
6
{
7
    private $api;
8
9
    /** @var string */
10
    protected $base;
11
12
    /** @var string */
13
    protected $table;
14
15
    public function __construct($client, $table)
16
    {
17
        $this->table = $table;
18
        $this->api = $client;
19
    }
20
21
    public function find(string $id)
22
    {
23
        return $this->api->get($id);
24
    }
25
26
    public function create($data)
27
    {
28
        return $this->api->post($data);
29
    }
30
31
    public function update(string $id, $data)
32
    {
33
        return $this->api->put($id, $data);
34
    }
35
36
    public function destroy(string $id)
37
    {
38
        return $this->api->delete($id);
39
    }
40
41
    public function where($column, $value)
42
    {
43
        return $this->api->where($column, $value);
44
    }
45
46
    public function firstOrCreate(array $idData, array $createData = [])
47
    {
48
        return $this->api->firstOrCreate($idData, $createData);
49
    }
50
51
    public function createOrUpdate(array $idData, array $updateData = [])
52
    {
53
        return $this->api->createOrUpdate($idData, $updateData);
54
    }
55
56
    public function get()
57
    {
58
        return $this->api->get();
59
    }
60
61
    public function all()
62
    {
63
        return $this->api->getAllPages();
64
    }
65
}
66