Driver::getFullPath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Traincase\HtmlToPdfTinker\Drivers;
4
5
use League\Flysystem\Filesystem;
6
use Traincase\HtmlToPdfTinker\DTO\PdfToGenerateDTO;
7
use Traincase\HtmlToPdfTinker\Exceptions\UnsupportedOutputTypeException;
8
9
abstract class Driver
10
{
11
    /**
12
     * Create the PDF and return it in string format.
13
     *
14
     * @param Filesystem $filesystem Filesystem used for storing the PDF
15
     * @param PdfToGenerateDTO $dto Data needed to generate the PDF file
16
     * @return string Filepath to the generated PDF file
17
     * @throws UnsupportedOutputTypeException
18
     */
19
    abstract public function storeOnFilesystem(Filesystem $filesystem, PdfToGenerateDTO $dto): string;
20
21
    /**
22
     * Get the full path to a file based on a path and a filename;
23
     *
24
     * @param string $path
25
     * @param string $filename
26
     * @return string
27
     */
28 4
    public function getFullPath(string $path, string $filename): string
29
    {
30 4
        if ($path !== '/') {
31 4
            $path = rtrim($path, '/');
32
        }
33
34 4
        return "{$path}/{$filename}";
35
    }
36
}
37