| Conditions | 5 |
| Paths | 8 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 | $handle = fopen('php://memory', 'w'); |
||
| 22 | |||
| 23 | fputs($handle, $string); |
||
| 24 | rewind($handle); |
||
| 25 | |||
| 26 | $entries = array(); |
||
| 27 | while ($row = fgetcsv($handle)) { |
||
| 28 | $entries[$row[0]] = $row[1]; |
||
| 29 | } |
||
| 30 | |||
| 31 | fclose($handle); |
||
| 32 | |||
| 33 | if ($entries) { |
||
|
|
|||
| 34 | foreach ($entries as $original => $translation) { |
||
| 35 | $translations->insert(null, $original)->setTranslation($translation); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return $translations; |
||
| 40 | } |
||
| 41 | } |
||
| 42 |
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.