Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
HTML
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 load
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * This file is part of PHPWord - A pure PHP library for reading and writing
5 * word processing documents.
6 *
7 * PHPWord is free software distributed under the terms of the GNU Lesser
8 * General Public License version 3 as published by the Free Software Foundation.
9 *
10 * For the full copyright and license information, please read the LICENSE
11 * file that was distributed with this source code. For the full list of
12 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
13 *
14 * @see         https://github.com/PHPOffice/PHPWord
15 *
16 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17 */
18
19namespace PhpOffice\PhpWord\Reader;
20
21use Exception;
22use PhpOffice\PhpWord\PhpWord;
23use PhpOffice\PhpWord\Shared\Html as HTMLParser;
24
25/**
26 * HTML Reader class.
27 *
28 * @since 0.11.0
29 */
30class HTML extends AbstractReader implements ReaderInterface
31{
32    /**
33     * Loads PhpWord from file.
34     *
35     * @param string $docFile
36     *
37     * @return PhpWord
38     */
39    public function load($docFile)
40    {
41        $phpWord = new PhpWord();
42
43        if ($this->canRead($docFile)) {
44            $section = $phpWord->addSection();
45            HTMLParser::addHtml($section, file_get_contents($docFile), true);
46        } else {
47            throw new Exception("Cannot read {$docFile}.");
48        }
49
50        return $phpWord;
51    }
52}