Completed
Push — master ( fcf66f...4020b1 )
by Sam
02:59
created

Repository::setApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Xtools;
4
5
use Doctrine\DBAL\Connection;
6
use Mediawiki\Api\MediawikiApi;
7
use Psr\Cache\CacheItemPoolInterface;
8
9
/**
10
 * A repository is responsible for retrieving data from wherever it lives (databases, APIs,
11
 * filesystems, etc.)
12
 */
13
abstract class Repository
14
{
15
16
    /** @var Connection */
17
    protected $metaConnection;
18
19
    /** @var Connection */
20
    protected $projectsConnection;
21
22
    /** @var Connection */
23
    protected $toolsConnection;
24
25
    /** @var MediawikiApi */
26
    protected $api;
27
28
    /** @var CacheItemPoolInterface */
29
    private $cache;
30
31
    /**
32
     * Set the database connection for the 'meta' database.
33
     * @param Connection $connection
34
     */
35
    public function setMetaConnection(Connection $connection)
36
    {
37
        $this->metaConnection = $connection;
38
    }
39
40
    /**
41
     * Set the database connection for the 'projects' database.
42
     * @param Connection $connection
43
     */
44
    public function setProjectsConnection(Connection $connection)
45
    {
46
        $this->projectsConnection = $connection;
47
    }
48
49
    /**
50
     * Set the database connection for the 'tools' database.
51
     * @param Connection $connection
52
     */
53
    public function setToolsConnection(Connection $connection)
54
    {
55
        $this->toolsConnection = $connection;
56
    }
57
58
    /**
59
     * @param MediawikiApi $api
60
     */
61
    public function setApi(MediawikiApi $api)
62
    {
63
        $this->api = $api;
64
    }
65
66
    /**
67
     * Normalize and quote a table name.
68
     *
69
     * @param string $databaseName
70
     * @param string $tableName
71
     * @return string Fully-qualified and quoted table name.
72
     */
73
    public function getTableName($databaseName, $tableName)
74
    {
75
        // @TODO Import from LabsHelper.
76
        return "`$databaseName`.`$tableName`";
77
    }
78
79
    /**
80
     * Set the cache for this repository.
81
     *
82
     * @param CacheItemPoolInterface $pool The cache pool.
83
     */
84
    public function setCache(CacheItemPoolInterface $pool)
85
    {
86
        $this->cache = $pool;
87
    }
88
}
89