Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_translation_TranslationFileReader | |
0.00% |
0 / 11 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| read | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getTranslationFile | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| getFilePath | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| setFilePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setTranslationFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * A Reading class for TranslationFiles. Must be implemented by a concrete class |
| 27 | * a given Translation Format such as XLIFF, PO, ... The read method must be |
| 28 | * by subclasses. |
| 29 | * |
| 30 | * @abstract |
| 31 | * @access public |
| 32 | * @author Jerome Bogaerts |
| 33 | * @package tao |
| 34 | * @since 2.2 |
| 35 | |
| 36 | * @version 1.0 |
| 37 | */ |
| 38 | abstract class tao_helpers_translation_TranslationFileReader |
| 39 | { |
| 40 | // --- ASSOCIATIONS --- |
| 41 | |
| 42 | |
| 43 | // --- ATTRIBUTES --- |
| 44 | |
| 45 | /** |
| 46 | * Short description of attribute filePath |
| 47 | * |
| 48 | * @access private |
| 49 | * @var string |
| 50 | */ |
| 51 | private $filePath = ''; |
| 52 | |
| 53 | /** |
| 54 | * Short description of attribute translationFile |
| 55 | * |
| 56 | * @access private |
| 57 | * @var TranslationFile |
| 58 | */ |
| 59 | private $translationFile = null; |
| 60 | |
| 61 | // --- OPERATIONS --- |
| 62 | |
| 63 | /** |
| 64 | * Creates a new instance of TranslationFileReader. |
| 65 | * |
| 66 | * @access public |
| 67 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 68 | * @param string filePath |
| 69 | * @return mixed |
| 70 | */ |
| 71 | public function __construct($filePath) |
| 72 | { |
| 73 | |
| 74 | $this->filePath = $filePath; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Reads a translation file to put TranslationUnits of the TranslationFile |
| 79 | * memory. Retrieved strings must be unescaped to avoid any misunderstanding |
| 80 | * the client code. This method must be implemented by subclasses. |
| 81 | * |
| 82 | * @abstract |
| 83 | * @access public |
| 84 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 85 | * @return mixed |
| 86 | */ |
| 87 | abstract public function read(); |
| 88 | |
| 89 | /** |
| 90 | * Gets the TranslationFile instance resulting of the reading of the file. |
| 91 | * |
| 92 | * @access public |
| 93 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 94 | * @return tao_helpers_translation_TranslationFile |
| 95 | */ |
| 96 | public function getTranslationFile() |
| 97 | { |
| 98 | $returnValue = null; |
| 99 | |
| 100 | |
| 101 | if ($this->translationFile != null) { |
| 102 | return $this->translationFile; |
| 103 | } else { |
| 104 | throw new tao_helpers_translation_TranslationException('No TranslationFile to retrieve.'); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | return $returnValue; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Gets the location where the file has to be read. |
| 113 | * |
| 114 | * @access public |
| 115 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 116 | * @return string |
| 117 | */ |
| 118 | public function getFilePath() |
| 119 | { |
| 120 | $returnValue = (string) ''; |
| 121 | |
| 122 | |
| 123 | return $this->filePath; |
| 124 | |
| 125 | |
| 126 | return (string) $returnValue; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Sets the location where the file has to be read. |
| 131 | * |
| 132 | * @access public |
| 133 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 134 | * @param string filePath |
| 135 | * @return mixed |
| 136 | */ |
| 137 | public function setFilePath($filePath) |
| 138 | { |
| 139 | |
| 140 | $this->filePath = $filePath; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Short description of method setTranslationFile |
| 145 | * |
| 146 | * @access public |
| 147 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 148 | * @param TranslationFile translationFile |
| 149 | * @return mixed |
| 150 | */ |
| 151 | public function setTranslationFile(tao_helpers_translation_TranslationFile $translationFile) |
| 152 | { |
| 153 | |
| 154 | $this->translationFile = $translationFile; |
| 155 | } |
| 156 | } |