Created
January 16, 2015 23:59
-
-
Save vlakoff/2f1acfa71068a4729033 to your computer and use it in GitHub Desktop.
Stringy - Quick check for proposed changes in $charsArray
This file contains hidden or 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 | |
require './vendor/autoload.php'; | |
use Patchwork\Utf8; | |
use Stringy\Stringy; | |
class MyStringy extends Stringy { | |
public function charsArray() { | |
return parent::charsArray(); | |
} | |
} | |
$charsArray = MyStringy::create('foobar')->charsArray(); | |
$proposal = array( /*...*/ ); | |
foreach ($charsArray as $to => $from) { | |
if (!isset($proposal[$to])) { | |
exit('index removed'); | |
} | |
$diff = array_diff($from, $proposal[$to]); | |
if ($diff) { | |
exit('characters removed'); | |
} | |
$diff = array_diff($proposal[$to], $from); | |
if ($diff) { | |
echo $to, "\n"; | |
foreach ($diff as $char) { | |
echo " {$char} : ", ($to === Utf8::toAscii($char) ? 'OK' : 'FAIL'), "\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment