This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Clean a string and return it with only letters, numbers, «.», «-» and «_» | |
* Spaces are replaced by «_» | |
*/ | |
public function cleanName(string $filename) : string | |
{ | |
return preg_replace("/[^.a-zA-Z0-9_-]+/", "", | |
transliterator_transliterate('Any-Latin;Latin-ASCII;', | |
str_replace(' ', '_', $filename))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
final class ImageFactory | |
{ | |
public static function getResource(string $filePath): \GdImage | |
{ | |
if (!is_file($filePath)) { | |
throw new IOException('File «' . $filePath . '» was not found'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
/** | |
* Created by PhpStorm. | |
* User: david | |
* Date: 15/02/2017 | |
* Time: 08:01 | |
*/ | |
namespace AppBundle\Services; |