PersistentDataStoreFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 24
ccs 3
cts 6
cp 0.5
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A makePersistentDataStore() 0 12 4
1
<?php
2
namespace Dropbox\Store;
3
4
use InvalidArgumentException;
5
6
/**
7
 * Thanks to Facebook
8
 *
9
 * @link https://developers.facebook.com/docs/php/PersistentDataInterface
10
 */
11
class PersistentDataStoreFactory
12
{
13
    /**
14
     * Make Persistent Data Store
15
     *
16
     * @param null|string|\Dropbox\Store\PersistentDataStoreInterface $store
17
     *
18
     * @throws InvalidArgumentException
19
     *
20
     * @return \Dropbox\Store\PersistentDataStoreInterface
21
     */
22 58
    public static function makePersistentDataStore($store = null)
23
    {
24 58
        if (is_null($store) || $store === 'session') {
25 58
            return new SessionPersistentDataStore();
26
        }
27
28
        if ($store instanceof PersistentDataStoreInterface) {
29
            return $store;
30
        }
31
32
        throw new InvalidArgumentException('The persistent data store must be set to null, "session" or be an instance of use \Dropbox\Store\PersistentDataStoreInterface');
33
    }
34
}
35