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

HtmlHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadHtmlIntoSpreadsheet() 0 9 2
A createHtml() 0 6 1
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