UberMongo::setConnection()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 2
eloc 7
nc 3
nop 2
1
<?php
2
3
namespace Sleepness\UberTranslationBundle\Storage;
4
5
use Symfony\Component\Config\Resource\ResourceInterface;
6
7
/**
8
 * Wrapper under standard MongoClient
9
 *
10
 * @author Viktor Novikov <[email protected]>
11
 */
12
class UberMongo implements ResourceInterface, UberStorageInterface
13
{
14
    /**
15
     * @var \MongoDB|null
16
     */
17
    private $mongoDB = null;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function setConnection($host = 'localhost', $port = '27017')
23
    {
24
        try {
25
            $client = new \MongoClient("mongodb://$host:$port");
26
            $this->mongoDB = new \MongoDB($client, 'uber_translations');
27
28
            return true;
29
        } catch (\Exception $exception) {
30
            return false;
31
        }
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function addItem($key, $value, $expiration = null)
38
    {
39
        // TODO: Implement addItem() method.
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getItem($key)
46
    {
47
        // TODO: Implement getItem() method.
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getAllKeys()
54
    {
55
        // TODO: Implement getAllKeys() method.
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function deleteItem($key)
62
    {
63
        // TODO: Implement deleteItem() method.
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function dropCache()
70
    {
71
        // TODO: Implement dropCache() method.
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function isFresh($timestamp)
78
    {
79
        // TODO: Implement isFresh() method.
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function getResource()
86
    {
87
        // TODO: Implement getResource() method.
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function __toString()
94
    {
95
        return 'uberMongo';
96
    }
97
}
98