switch( pathinfo( $filename, PATHINFO_EXTENSION ) ) {
case 'jpeg':
case 'jpg': $image = imagecreatefromjpeg($filename); break;
case 'png': $image = imagecreatefrompng($filename); break;
default: break;
}
$width = imagesx($image);
$height = imagesy($image);
Optionally, all whitelisted files can be added to the code coverage report by setting addUncoveredFilesFromWhitelist="true" in your PHPUnit configuration
<?php
function getRows($file) {
$handle = fopen($file, 'rb');
if ($handle === false) {
throw new Exception();
}
while (feof($handle) === false) {
yield fgetcsv($handle);
}
fclose($handle);
}
foreach (getRows('data.csv') as $row) {
print_r($row);
}