PathFinder::getTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Pumpkin\Database;
3
4
/**
5
 * Class PathFinder
6
 * Finds file path for table.
7
 *
8
 * @package Pumpkin
9
 * @author Raphaël Lefebvre <[email protected]>
10
 */
11
class PathFinder
12
{
13
14
    /**
15
     * @var Table
16
     */
17
    private $table;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param Table $table
23
     */
24 9
    public function __construct(Table $table)
25
    {
26 9
        $this->setTable($table);
27 9
    }
28
29
30
    /**
31
     * @param string[] $supportedExtensions
32
     * @return string
33
     * @throws \RuntimeException
34
     */
35 9
    public function findDataPath(array $supportedExtensions)
36
    {
37 9
        $pathFinder = new \Pumpkin\Test\PathFinder($this->getTable()->getTest());
38 9
        return $pathFinder->findPath($this->getFileSubPath(), $supportedExtensions);
39
    }
40
41
    /**
42
     * @return string
43
     */
44 9
    private function getFileSubPath()
45
    {
46 9
        return sprintf(
47 9
            '/fixtures/databases/%s/data/%s',
48 9
            $this->getTable()->getDataBaseName(),
49 9
            $this->getTable()->getName()
50 9
        );
51
    }
52
53
    /**
54
     * @param Table $table
55
     */
56 9
    private function setTable(Table $table)
57
    {
58 9
        $this->table = $table;
59 9
    }
60
61
    /**
62
     * @return Table
63
     */
64 9
    private function getTable()
65
    {
66 9
        return $this->table;
67
    }
68
}
69