| Conditions | 5 |
| Paths | 8 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function fromString($string, Translations $translations = null, $file = '') |
||
| 16 | { |
||
| 17 | if ($translations === null) { |
||
| 18 | $translations = new Translations(); |
||
| 19 | } |
||
| 20 | |||
| 21 | $tmpFile = tempnam(sys_get_temp_dir(), 'gettext_'); |
||
| 22 | file_put_contents($tmpFile, $string); |
||
| 23 | $handle = fopen($tmpFile, 'r'); |
||
| 24 | |||
| 25 | $entries = array(); |
||
| 26 | while ($row = fgetcsv($handle)) { |
||
| 27 | $entries[$row[0]] = $row[1]; |
||
| 28 | } |
||
| 29 | |||
| 30 | fclose($handle); |
||
| 31 | |||
| 32 | if ($entries) { |
||
|
|
|||
| 33 | foreach ($entries as $original => $translation) { |
||
| 34 | $translations->insert(null, $original)->setTranslation($translation); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $translations; |
||
| 39 | } |
||
| 40 | } |
||
| 41 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.