Conditions | 6 |
Paths | 6 |
Total Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public static function factory($config) |
||
17 | { |
||
18 | switch ($config['save.handler']) { |
||
19 | case 'file': |
||
20 | return new Xhgui_Saver_File($config['save.handler.filename']); |
||
21 | |||
22 | case 'upload': |
||
23 | $timeout = 3; |
||
24 | if (isset($config['save.handler.upload.timeout'])) { |
||
25 | $timeout = $config['save.handler.upload.timeout']; |
||
26 | } |
||
27 | return new Xhgui_Saver_Upload( |
||
28 | $config['save.handler.upload.uri'], |
||
29 | $timeout |
||
30 | ); |
||
31 | |||
32 | case 'pdo': |
||
33 | return new Xhgui_Saver_Pdo( |
||
34 | new PDO( |
||
35 | $config['pdo']['dsn'], |
||
36 | $config['pdo']['user'], |
||
37 | $config['pdo']['pass'] |
||
38 | ), |
||
39 | $config['pdo']['table'] |
||
40 | ); |
||
41 | |||
42 | case 'mongodb': |
||
43 | default: |
||
44 | $mongo = new MongoClient($config['db.host'], $config['db.options'], $config['db.driverOptions']); |
||
45 | $collection = $mongo->{$config['db.db']}->results; |
||
46 | $collection->findOne(); |
||
47 | return new Xhgui_Saver_Mongo($collection); |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 |