Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
28 | 3 | #[\Override] |
|
29 | public function loadTemplate(string $templateName): string |
||
30 | { |
||
31 | 3 | $stmt = $this->pdo->prepare('SELECT content FROM templates WHERE name = :name'); |
|
32 | |||
33 | 3 | $stmt->execute(['name' => $templateName]); |
|
34 | |||
35 | /** |
||
36 | * @var false|string $content |
||
37 | */ |
||
38 | 3 | $content = $stmt->fetchColumn(); |
|
39 | |||
40 | 3 | if ($content === false) { |
|
41 | 1 | throw TemplateNotFoundException::forDatabaseTemplate($templateName); |
|
42 | } |
||
43 | |||
44 | 2 | if ($content === '') { |
|
45 | 1 | throw TemplateHasNoContentException::create($templateName); |
|
46 | } |
||
47 | |||
48 | 1 | return $content; |
|
49 | } |
||
51 |