GoogleDataStore::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Previewtechs\HTTP\AccessLogger\Providers;
4
5
use GDS\Store;
6
use Previewtechs\HTTP\AccessLogger\StorageInterface;
7
8
/**
9
 * Class GoogleDataStore
10
 * @package Previewtechs\HTTP\AccessLogger\Providers
11
 */
12
class GoogleDataStore implements StorageInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    public $data = [];
18
19
    /**
20
     * @var Store $gds
21
     */
22
    private $gds;
23
24
    /**
25
     * GoogleDataStore constructor.
26
     * @param $client
27
     */
28 3
    public function __construct($client)
29
    {
30 3
        $this->gds = $client;
31 3
    }
32
33
    /**
34
     * @param array $data
35
     * @return mixed
36
     */
37 1
    public function save($data = [])
38
    {
39 1
        $this->data = $data;
40
41 1
        $entities = $this->gds->createEntity($this->data);
42 1
        return $this->gds->upsert($entities);
43
    }
44
45
    /**
46
     * @return array
47
     */
48 1
    public function getData()
49
    {
50 1
        return $this->data;
51
    }
52
}
53