Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RTF | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| load | |
100.00% |
7 / 7 |
|
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 | |
| 19 | namespace PhpOffice\PhpWord\Reader; |
| 20 | |
| 21 | use Exception; |
| 22 | use PhpOffice\PhpWord\PhpWord; |
| 23 | use PhpOffice\PhpWord\Reader\RTF\Document; |
| 24 | |
| 25 | /** |
| 26 | * RTF Reader class. |
| 27 | * |
| 28 | * @since 0.11.0 |
| 29 | */ |
| 30 | class RTF 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 | $doc = new Document(); |
| 45 | $doc->rtf = file_get_contents($docFile); |
| 46 | $doc->read($phpWord); |
| 47 | } else { |
| 48 | throw new Exception("Cannot read {$docFile}."); |
| 49 | } |
| 50 | |
| 51 | return $phpWord; |
| 52 | } |
| 53 | } |