Skip to content

Instantly share code, notes, and snippets.

View chindit's full-sized avatar
🦙
Lama, what else ?

David Lumaye chindit

🦙
Lama, what else ?
View GitHub Profile
@chindit
chindit / cleanString.php
Created August 6, 2017 10:47
Clean a string to latin equivalent
<?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)));
@chindit
chindit / ImageFactory.php
Last active February 14, 2021 18:05
FilePath to GD resource
<?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');
<?php
declare(strict_types = 1);
/**
* Created by PhpStorm.
* User: david
* Date: 15/02/2017
* Time: 08:01
*/
namespace AppBundle\Services;