GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0c55ca...41083b )
by Richard
9s
created

MongoDBStorageAdapter::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Opensoft\Rollout\Storage;
4
5
/**
6
 * Storage adapter using MongoDB
7
 *
8
 * @author James Hrisho <@securingsincity>
9
 */
10
class MongoDBStorageAdapter implements StorageInterface
11
{
12
13
    /**
14
     * @var object
15
     */
16
    private $mongo;
17
18
    /**
19
     * @var string
20
     */
21
    private $collection;
22
23
    public function __construct($mongo, $collection = "rollout_feature")
24
    {
25
        $this->mongo = $mongo;
26
        $this->collection = $collection;
27
    }
28
    public function getCollectionName()
29
    {
30
        return $this->collection;
31
    }
32
    /**
33
     * @inheritdoc
34
     */
35
    public function get($key)
36
    {
37
        $collection = $this->getCollectionName();
38
        $result = $this->mongo->$collection->findOne(['name' => $key]);
39
40
        if (!$result) {
41
            return null;
42
        }
43
44
        return $result['value'];
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function set($key, $value)
51
    {
52
        $collection = $this->getCollectionName();
53
        $this->mongo->$collection->update(['name' => $key], ['$set' => ['value' => $value]], ['upsert' => true]);
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function remove($key)
60
    {
61
        $collection = $this->getCollectionName();
62
        $this->mongo->$collection->remove(['name' => $key]);
63
    }
64
65
}
66