Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Faker\Provider; use Faker\Generator; use Faker\DefaultGenerator; use Fake..

Decoded Output download

<?php
 namespace Faker\Provider; use Faker\Generator; use Faker\DefaultGenerator; use Faker\UniqueGenerator; use Faker\ValidGenerator; class Base { protected $generator; protected $unique; public function __construct(Generator $generator) { $this->generator = $generator; } public static function randomDigit() { return mt_rand(0, 9); } public static function randomDigitNotNull() { return mt_rand(1, 9); } public static function randomDigitNot($except) { $result = self::numberBetween(0, 8); if ($result >= $except) { $result++; } return $result; } public static function randomNumber($nbDigits = null, $strict = false) { if (!is_bool($strict)) { throw new \InvalidArgumentException("randomNumber() generates numbers of fixed width. To generate numbers between two boundaries, use numberBetween() instead."); } if (null === $nbDigits) { $nbDigits = static::randomDigitNotNull(); } $max = pow(10, $nbDigits) - 1; if ($max > mt_getrandmax()) { throw new \InvalidArgumentException("randomNumber() can only generate numbers up to mt_getrandmax()"); } if ($strict) { return mt_rand(pow(10, $nbDigits - 1), $max); } return mt_rand(0, $max); } public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null) { if (null === $nbMaxDecimals) { $nbMaxDecimals = static::randomDigit(); } if (null === $max) { $max = static::randomNumber(); if ($min > $max) { $max = $min; } } if ($min > $max) { $tmp = $min; $min = $max; $max = $tmp; } return round($min + mt_rand() / mt_getrandmax() * ($max - $min), $nbMaxDecimals); } public static function numberBetween($int1 = 0, $int2 = 2147483647) { $min = $int1 < $int2 ? $int1 : $int2; $max = $int1 < $int2 ? $int2 : $int1; return mt_rand($min, $max); } public static function passthrough($value) { return $value; } public static function randomLetter() { return chr(mt_rand(97, 122)); } public static function randomAscii() { return chr(mt_rand(33, 126)); } public static function randomElements($array = array("a", "b", "c"), $count = 1, $allowDuplicates = false) { $traversables = array(); if ($array instanceof \Traversable) { foreach ($array as $element) { $traversables[] = $element; } } $arr = count($traversables) ? $traversables : $array; $allKeys = array_keys($arr); $numKeys = count($allKeys); if (!$allowDuplicates && $numKeys < $count) { throw new \LengthException(sprintf("Cannot get %d elements, only %d in array", $count, $numKeys)); } $highKey = $numKeys - 1; $keys = $elements = array(); $numElements = 0; while ($numElements < $count) { $num = mt_rand(0, $highKey); if (!$allowDuplicates) { if (isset($keys[$num])) { continue; } $keys[$num] = true; } $elements[] = $arr[$allKeys[$num]]; $numElements++; } return $elements; } public static function randomElement($array = array("a", "b", "c")) { if (!$array || $array instanceof \Traversable && !count($array)) { return null; } $elements = static::randomElements($array, 1); return $elements[0]; } public static function randomKey($array = array()) { if (!$array) { return null; } $keys = array_keys($array); $key = $keys[mt_rand(0, count($keys) - 1)]; return $key; } public static function shuffle($arg = '') { if (is_array($arg)) { return static::shuffleArray($arg); } if (is_string($arg)) { return static::shuffleString($arg); } throw new \InvalidArgumentException("shuffle() only supports strings or arrays"); } public static function shuffleArray($array = array()) { $shuffledArray = array(); $i = 0; reset($array); foreach ($array as $key => $value) { if ($i == 0) { $j = 0; } else { $j = mt_rand(0, $i); } if ($j == $i) { $shuffledArray[] = $value; } else { $shuffledArray[] = $shuffledArray[$j]; $shuffledArray[$j] = $value; } $i++; } return $shuffledArray; } public static function shuffleString($string = '', $encoding = "UTF-8") { if (function_exists("mb_strlen")) { $array = array(); $strlen = mb_strlen($string, $encoding); for ($i = 0; $i < $strlen; $i++) { $array[] = mb_substr($string, $i, 1, $encoding); } } else { $array = str_split($string, 1); } return implode('', static::shuffleArray($array)); } private static function replaceWildcard($string, $wildcard = "#", $callback = "static::randomDigit") { if (($pos = strpos($string, $wildcard)) === false) { return $string; } for ($i = $pos, $last = strrpos($string, $wildcard, $pos) + 1; $i < $last; $i++) { if ($string[$i] === $wildcard) { $string[$i] = call_user_func($callback); } } return $string; } public static function numerify($string = "###") { $toReplace = array(); if (($pos = strpos($string, "#")) !== false) { for ($i = $pos, $last = strrpos($string, "#", $pos) + 1; $i < $last; $i++) { if ($string[$i] === "#") { $toReplace[] = $i; } } } if ($nbReplacements = count($toReplace)) { $maxAtOnce = strlen((string) mt_getrandmax()) - 1; $numbers = ''; $i = 0; while ($i < $nbReplacements) { $size = min($nbReplacements - $i, $maxAtOnce); $numbers .= str_pad(static::randomNumber($size), $size, "0", STR_PAD_LEFT); $i += $size; } for ($i = 0; $i < $nbReplacements; $i++) { $string[$toReplace[$i]] = $numbers[$i]; } } $string = self::replaceWildcard($string, "%", "static::randomDigitNotNull"); return $string; } public static function lexify($string = "????") { return self::replaceWildcard($string, "?", "static::randomLetter"); } public static function bothify($string = "## ??") { $string = self::replaceWildcard($string, "*", function () { return mt_rand(0, 1) ? "#" : "?"; }); return static::lexify(static::numerify($string)); } public static function asciify($string = "****") { return preg_replace_callback("/\*/u", "static::randomAscii", $string); } public static function regexify($regex = '') { $regex = preg_replace("/^\/?\^?/", '', $regex); $regex = preg_replace("/\$?\/?$/", '', $regex); $regex = preg_replace("/\{(\d+)\}/", "{\1,\1}", $regex); $regex = preg_replace("/(?<!\\)\?/", "{0,1}", $regex); $regex = preg_replace("/(?<!\\)\*/", "{0," . static::randomDigitNotNull() . "}", $regex); $regex = preg_replace("/(?<!\\)\+/", "{1," . static::randomDigitNotNull() . "}", $regex); $regex = preg_replace_callback("/(\[[^\]]+\])\{(\d+),(\d+)\}/", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("/(\([^\)]+\))\{(\d+),(\d+)\}/", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("/(\\?.)\{(\d+),(\d+)\}/", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("/\((.*?)\)/", function ($matches) { return Base::randomElement(explode("|", str_replace(array("(", ")"), '', $matches[1]))); }, $regex); $regex = preg_replace_callback("/\[([^\]]+)\]/", function ($matches) { return "[" . preg_replace_callback("/(\w|\d)\-(\w|\d)/", function ($range) { return implode('', range($range[1], $range[2])); }, $matches[1]) . "]"; }, $regex); $regex = preg_replace_callback("/\[([^\]]+)\]/", function ($matches) { return Base::randomElement(str_split($matches[1])); }, $regex); $regex = preg_replace_callback("/\\w/", "static::randomLetter", $regex); $regex = preg_replace_callback("/\\d/", "static::randomDigit", $regex); $regex = preg_replace_callback("/(?<!\\)\./", "static::randomAscii", $regex); $regex = str_replace("\", '', $regex); return $regex; } public static function toLower($string = '') { return extension_loaded("mbstring") ? mb_strtolower($string, "UTF-8") : strtolower($string); } public static function toUpper($string = '') { return extension_loaded("mbstring") ? mb_strtoupper($string, "UTF-8") : strtoupper($string); } public function optional($weight = 0.5, $default = null) { if ($weight > 0 && $weight < 1 && mt_rand() / mt_getrandmax() <= $weight) { return $this->generator; } if (is_int($weight) && mt_rand(1, 100) <= $weight) { return $this->generator; } return new DefaultGenerator($default); } public function unique($reset = false, $maxRetries = 10000) { if ($reset || !$this->unique) { $this->unique = new UniqueGenerator($this->generator, $maxRetries); } return $this->unique; } public function valid($validator = null, $maxRetries = 10000) { return new ValidGenerator($this->generator, $validator, $maxRetries); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Faker\Provider; use Faker\Generator; use Faker\DefaultGenerator; use Faker\UniqueGenerator; use Faker\ValidGenerator; class Base { protected $generator; protected $unique; public function __construct(Generator $generator) { $this->generator = $generator; } public static function randomDigit() { return mt_rand(0, 9); } public static function randomDigitNotNull() { return mt_rand(1, 9); } public static function randomDigitNot($except) { $result = self::numberBetween(0, 8); if ($result >= $except) { $result++; } return $result; } public static function randomNumber($nbDigits = null, $strict = false) { if (!is_bool($strict)) { throw new \InvalidArgumentException("\x72\141\156\144\x6f\x6d\116\165\155\x62\145\x72\x28\51\40\x67\145\156\x65\162\x61\164\x65\163\40\x6e\165\x6d\x62\145\x72\163\40\x6f\x66\40\x66\151\x78\x65\144\40\167\x69\144\164\150\56\40\124\157\40\147\145\x6e\x65\162\x61\x74\x65\x20\156\x75\155\142\145\x72\x73\40\x62\145\x74\x77\145\x65\x6e\x20\x74\167\157\x20\142\157\x75\x6e\144\141\x72\151\145\163\x2c\40\165\163\145\40\x6e\165\x6d\x62\x65\162\102\145\x74\x77\x65\145\x6e\x28\x29\40\151\156\x73\164\145\x61\x64\x2e"); } if (null === $nbDigits) { $nbDigits = static::randomDigitNotNull(); } $max = pow(10, $nbDigits) - 1; if ($max > mt_getrandmax()) { throw new \InvalidArgumentException("\162\141\156\144\157\155\116\x75\155\x62\145\x72\50\51\x20\143\x61\x6e\40\157\x6e\x6c\x79\x20\x67\x65\156\x65\x72\x61\x74\x65\x20\x6e\165\155\x62\x65\162\163\40\x75\160\40\164\157\40\x6d\164\137\x67\x65\x74\x72\141\x6e\144\155\141\170\50\x29"); } if ($strict) { return mt_rand(pow(10, $nbDigits - 1), $max); } return mt_rand(0, $max); } public static function randomFloat($nbMaxDecimals = null, $min = 0, $max = null) { if (null === $nbMaxDecimals) { $nbMaxDecimals = static::randomDigit(); } if (null === $max) { $max = static::randomNumber(); if ($min > $max) { $max = $min; } } if ($min > $max) { $tmp = $min; $min = $max; $max = $tmp; } return round($min + mt_rand() / mt_getrandmax() * ($max - $min), $nbMaxDecimals); } public static function numberBetween($int1 = 0, $int2 = 2147483647) { $min = $int1 < $int2 ? $int1 : $int2; $max = $int1 < $int2 ? $int2 : $int1; return mt_rand($min, $max); } public static function passthrough($value) { return $value; } public static function randomLetter() { return chr(mt_rand(97, 122)); } public static function randomAscii() { return chr(mt_rand(33, 126)); } public static function randomElements($array = array("\141", "\142", "\143"), $count = 1, $allowDuplicates = false) { $traversables = array(); if ($array instanceof \Traversable) { foreach ($array as $element) { $traversables[] = $element; } } $arr = count($traversables) ? $traversables : $array; $allKeys = array_keys($arr); $numKeys = count($allKeys); if (!$allowDuplicates && $numKeys < $count) { throw new \LengthException(sprintf("\x43\x61\x6e\x6e\x6f\x74\40\147\145\x74\40\x25\x64\x20\145\x6c\x65\155\145\156\x74\163\x2c\x20\157\156\154\x79\40\x25\x64\x20\x69\156\x20\x61\162\162\141\171", $count, $numKeys)); } $highKey = $numKeys - 1; $keys = $elements = array(); $numElements = 0; while ($numElements < $count) { $num = mt_rand(0, $highKey); if (!$allowDuplicates) { if (isset($keys[$num])) { continue; } $keys[$num] = true; } $elements[] = $arr[$allKeys[$num]]; $numElements++; } return $elements; } public static function randomElement($array = array("\141", "\142", "\143")) { if (!$array || $array instanceof \Traversable && !count($array)) { return null; } $elements = static::randomElements($array, 1); return $elements[0]; } public static function randomKey($array = array()) { if (!$array) { return null; } $keys = array_keys($array); $key = $keys[mt_rand(0, count($keys) - 1)]; return $key; } public static function shuffle($arg = '') { if (is_array($arg)) { return static::shuffleArray($arg); } if (is_string($arg)) { return static::shuffleString($arg); } throw new \InvalidArgumentException("\163\x68\x75\146\146\154\145\x28\51\x20\157\x6e\x6c\171\40\163\165\160\x70\x6f\162\164\163\40\x73\x74\162\x69\x6e\x67\163\40\x6f\x72\x20\141\x72\162\x61\171\163"); } public static function shuffleArray($array = array()) { $shuffledArray = array(); $i = 0; reset($array); foreach ($array as $key => $value) { if ($i == 0) { $j = 0; } else { $j = mt_rand(0, $i); } if ($j == $i) { $shuffledArray[] = $value; } else { $shuffledArray[] = $shuffledArray[$j]; $shuffledArray[$j] = $value; } $i++; } return $shuffledArray; } public static function shuffleString($string = '', $encoding = "\x55\x54\x46\x2d\70") { if (function_exists("\155\x62\x5f\x73\x74\162\x6c\x65\x6e")) { $array = array(); $strlen = mb_strlen($string, $encoding); for ($i = 0; $i < $strlen; $i++) { $array[] = mb_substr($string, $i, 1, $encoding); } } else { $array = str_split($string, 1); } return implode('', static::shuffleArray($array)); } private static function replaceWildcard($string, $wildcard = "\x23", $callback = "\x73\x74\141\x74\151\143\x3a\x3a\x72\141\156\x64\157\155\x44\151\x67\151\164") { if (($pos = strpos($string, $wildcard)) === false) { return $string; } for ($i = $pos, $last = strrpos($string, $wildcard, $pos) + 1; $i < $last; $i++) { if ($string[$i] === $wildcard) { $string[$i] = call_user_func($callback); } } return $string; } public static function numerify($string = "\x23\x23\x23") { $toReplace = array(); if (($pos = strpos($string, "\43")) !== false) { for ($i = $pos, $last = strrpos($string, "\43", $pos) + 1; $i < $last; $i++) { if ($string[$i] === "\x23") { $toReplace[] = $i; } } } if ($nbReplacements = count($toReplace)) { $maxAtOnce = strlen((string) mt_getrandmax()) - 1; $numbers = ''; $i = 0; while ($i < $nbReplacements) { $size = min($nbReplacements - $i, $maxAtOnce); $numbers .= str_pad(static::randomNumber($size), $size, "\60", STR_PAD_LEFT); $i += $size; } for ($i = 0; $i < $nbReplacements; $i++) { $string[$toReplace[$i]] = $numbers[$i]; } } $string = self::replaceWildcard($string, "\x25", "\163\164\141\x74\x69\143\x3a\72\x72\x61\x6e\x64\x6f\155\x44\x69\147\151\164\116\157\x74\x4e\x75\x6c\154"); return $string; } public static function lexify($string = "\77\77\x3f\x3f") { return self::replaceWildcard($string, "\77", "\163\164\141\164\151\x63\72\x3a\x72\x61\156\x64\x6f\x6d\x4c\x65\x74\164\x65\x72"); } public static function bothify($string = "\x23\x23\40\x3f\x3f") { $string = self::replaceWildcard($string, "\52", function () { return mt_rand(0, 1) ? "\43" : "\77"; }); return static::lexify(static::numerify($string)); } public static function asciify($string = "\52\52\52\52") { return preg_replace_callback("\x2f\x5c\x2a\57\x75", "\x73\x74\141\x74\151\143\72\x3a\162\x61\156\144\157\x6d\x41\163\143\x69\151", $string); } public static function regexify($regex = '') { $regex = preg_replace("\57\x5e\x5c\x2f\77\134\136\77\x2f", '', $regex); $regex = preg_replace("\x2f\134\44\x3f\x5c\x2f\77\x24\x2f", '', $regex); $regex = preg_replace("\x2f\x5c\173\50\134\x64\53\x29\x5c\175\57", "\173\134\61\x2c\x5c\61\x7d", $regex); $regex = preg_replace("\57\x28\77\x3c\41\x5c\134\51\x5c\x3f\57", "\x7b\x30\x2c\x31\175", $regex); $regex = preg_replace("\57\x28\x3f\x3c\x21\x5c\x5c\x29\134\52\57", "\173\x30\54" . static::randomDigitNotNull() . "\x7d", $regex); $regex = preg_replace("\x2f\x28\77\x3c\x21\x5c\x5c\x29\x5c\53\x2f", "\173\61\x2c" . static::randomDigitNotNull() . "\x7d", $regex); $regex = preg_replace_callback("\57\50\x5c\133\133\136\134\x5d\x5d\53\134\135\51\x5c\x7b\x28\134\144\x2b\51\54\x28\x5c\144\53\x29\134\x7d\57", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("\57\50\134\50\133\x5e\134\51\x5d\53\134\x29\x29\134\x7b\x28\x5c\144\x2b\x29\x2c\x28\x5c\x64\x2b\x29\134\175\x2f", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("\57\50\134\134\x3f\56\51\x5c\x7b\x28\x5c\144\x2b\51\x2c\50\134\144\53\x29\134\175\57", function ($matches) { return str_repeat($matches[1], Base::randomElement(range($matches[2], $matches[3]))); }, $regex); $regex = preg_replace_callback("\57\134\50\50\x2e\52\x3f\51\134\x29\x2f", function ($matches) { return Base::randomElement(explode("\x7c", str_replace(array("\50", "\51"), '', $matches[1]))); }, $regex); $regex = preg_replace_callback("\x2f\x5c\x5b\50\x5b\x5e\134\135\x5d\53\x29\134\135\x2f", function ($matches) { return "\x5b" . preg_replace_callback("\57\x28\x5c\x77\x7c\134\144\x29\x5c\55\x28\x5c\x77\174\x5c\144\51\57", function ($range) { return implode('', range($range[1], $range[2])); }, $matches[1]) . "\135"; }, $regex); $regex = preg_replace_callback("\57\134\133\50\x5b\136\134\x5d\x5d\53\x29\x5c\135\x2f", function ($matches) { return Base::randomElement(str_split($matches[1])); }, $regex); $regex = preg_replace_callback("\57\134\x5c\x77\57", "\163\164\x61\164\151\143\72\72\x72\141\156\x64\157\x6d\114\x65\x74\164\x65\162", $regex); $regex = preg_replace_callback("\x2f\x5c\134\144\57", "\163\164\x61\x74\151\x63\72\72\162\x61\x6e\x64\157\x6d\104\151\x67\151\x74", $regex); $regex = preg_replace_callback("\57\50\77\x3c\41\134\x5c\x29\x5c\x2e\57", "\x73\x74\141\x74\x69\143\x3a\x3a\162\141\156\x64\157\x6d\x41\163\143\x69\151", $regex); $regex = str_replace("\x5c", '', $regex); return $regex; } public static function toLower($string = '') { return extension_loaded("\155\142\x73\x74\162\151\156\x67") ? mb_strtolower($string, "\125\124\106\x2d\70") : strtolower($string); } public static function toUpper($string = '') { return extension_loaded("\x6d\142\163\x74\x72\151\x6e\x67") ? mb_strtoupper($string, "\125\124\106\55\x38") : strtoupper($string); } public function optional($weight = 0.5, $default = null) { if ($weight > 0 && $weight < 1 && mt_rand() / mt_getrandmax() <= $weight) { return $this->generator; } if (is_int($weight) && mt_rand(1, 100) <= $weight) { return $this->generator; } return new DefaultGenerator($default); } public function unique($reset = false, $maxRetries = 10000) { if ($reset || !$this->unique) { $this->unique = new UniqueGenerator($this->generator, $maxRetries); } return $this->unique; } public function valid($validator = null, $maxRetries = 10000) { return new ValidGenerator($this->generator, $validator, $maxRetries); } }

Function Calls

None

Variables

None

Stats

MD5 1f4683f00ad361a95140e19f9f83197e
Eval Count 0
Decode Time 145 ms