Conditions | 5 |
Paths | 13 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
46 | public function get(SimpleCrud $db, $name) |
||
47 | { |
||
48 | try { |
||
49 | $className = ucfirst($name); |
||
50 | |||
51 | foreach ($this->namespaces as $namespace) { |
||
52 | $class = $namespace.$className; |
||
53 | |||
54 | if (class_exists($class)) { |
||
55 | return new $class($db, $name); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | if ($this->default) { |
||
60 | $class = $this->default; |
||
61 | |||
62 | return new $class($db, $name); |
||
63 | } |
||
64 | } catch (\Exception $exception) { |
||
65 | throw new SimpleCrudException("Error getting the '{$name}' table", 0, $exception); |
||
66 | } |
||
67 | |||
68 | throw new SimpleCrudException("Table '{$name}' not found"); |
||
69 | } |
||
70 | } |
||
71 |