Failed Conditions
Push — master ( 735103...6a4138 )
by Adrien
12:48
created

HtmlHelper::loadHtmlIntoSpreadsheet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
4
5
use PhpOffice\PhpSpreadsheet\Reader\Html;
6
use PhpOffice\PhpSpreadsheet\Spreadsheet;
7
8
class HtmlHelper
9
{
10
    public static function createHtml(string $html): string
11
    {
12
        $filename = tempnam(sys_get_temp_dir(), 'html');
13
        file_put_contents($filename, $html);
14
15
        return $filename;
16
    }
17
18
    public static function loadHtmlIntoSpreadsheet(string $filename, bool $unlink = false): Spreadsheet
19
    {
20
        $html = new Html();
21
        $spreadsheet = $html->load($filename);
22
        if ($unlink) {
23
            unlink($filename);
24
        }
25
26
        return $spreadsheet;
27
    }
28
}
29