| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775 |
- <?php
- /**
- * Laravel Helpers File
- * Extracted by Anthony Rappa
- * rappa819@gmail.com
- */
- if (!function_exists('append_config')) {
- /**
- * Assign high numeric IDs to a config item to force appending.
- *
- * @param array $array
- * @return array
- */
- function append_config(array $array)
- {
- $start = 9999;
- foreach ($array as $key => $value) {
- if (is_numeric($key)) {
- $start++;
- $array[$start] = array_pull($array, $key);
- }
- }
- return $array;
- }
- }
- if (!function_exists('array_add')) {
- /**
- * Add an element to an array using "dot" notation if it doesn't exist.
- *
- * @param array $array
- * @param string $key
- * @param mixed $value
- * @return array
- */
- function array_add($array, $key, $value)
- {
- if (is_null(get($array, $key))) {
- set($array, $key, $value);
- }
- return $array;
- }
- }
- if (!function_exists('array_build')) {
- /**
- * Build a new array using a callback.
- *
- * @param array $array
- * @param \Closure $callback
- * @return array
- */
- function array_build($array, Closure $callback)
- {
- $results = array();
- foreach ($array as $key => $value) {
- list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
- $results[$innerKey] = $innerValue;
- }
- return $results;
- }
- }
- if (!function_exists('array_divide')) {
- /**
- * Divide an array into two arrays. One with keys and the other with values.
- *
- * @param array $array
- * @return array
- */
- function array_divide($array)
- {
- return array(array_keys($array), array_values($array));
- }
- }
- if (!function_exists('array_dot')) {
- /**
- * Flatten a multi-dimensional associative array with dots.
- *
- * @param array $array
- * @param string $prepend
- * @return array
- */
- function array_dot($array, $prepend = '')
- {
- $results = array();
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $results = array_merge($results, dot($value, $prepend . $key . '.'));
- } else {
- $results[$prepend . $key] = $value;
- }
- }
- return $results;
- }
- }
- if (!function_exists('array_except')) {
- /**
- * Get all of the given array except for a specified array of items.
- *
- * @param array $array
- * @param array|string $keys
- * @return array
- */
- function array_except($array, $keys)
- {
- return array_diff_key($array, array_flip((array)$keys));
- }
- }
- if (!function_exists('array_fetch')) {
- /**
- * Fetch a flattened array of a nested array element.
- *
- * @param array $array
- * @param string $key
- * @return array
- */
- function array_fetch($array, $key)
- {
- $results = array();
- foreach (explode('.', $key) as $segment) {
- foreach ($array as $value) {
- if (array_key_exists($segment, $value = (array)$value)) {
- $results[] = $value[$segment];
- }
- }
- $array = array_values($results);
- }
- return array_values($results);
- }
- }
- if (!function_exists('array_first')) {
- /**
- * Return the first element in an array passing a given truth test.
- *
- * @param array $array
- * @param \Closure $callback
- * @param mixed $default
- * @return mixed
- */
- function array_first($array, $callback, $default = null)
- {
- foreach ($array as $key => $value) {
- if (call_user_func($callback, $key, $value)) {
- return $value;
- }
- }
- return value($default);
- }
- }
- if (!function_exists('array_last')) {
- /**
- * Return the last element in an array passing a given truth test.
- *
- * @param array $array
- * @param \Closure $callback
- * @param mixed $default
- * @return mixed
- */
- function array_last($array, $callback, $default = null)
- {
- return first(array_reverse($array), $callback, $default);
- }
- }
- if (!function_exists('array_flatten')) {
- /**
- * Flatten a multi-dimensional array into a single level.
- *
- * @param array $array
- * @return array
- */
- function array_flatten($array)
- {
- $return = array();
- array_walk_recursive($array, function ($x) use (&$return) {
- $return[] = $x;
- });
- return $return;
- }
- }
- if (!function_exists('array_forget')) {
- /**
- * Remove one or many array items from a given array using "dot" notation.
- *
- * @param array $array
- * @param array|string $keys
- * @return void
- */
- function array_forget(&$array, $keys)
- {
- $original =& $array;
- foreach ((array)$keys as $key) {
- $parts = explode('.', $key);
- while (count($parts) > 1) {
- $part = array_shift($parts);
- if (isset($array[$part]) && is_array($array[$part])) {
- $array =& $array[$part];
- }
- }
- unset($array[array_shift($parts)]);
- // clean up after each pass
- $array =& $original;
- }
- }
- }
- if (!function_exists('array_get')) {
- /**
- * Get an item from an array using "dot" notation.
- *
- * @param array $array
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function array_get($array, $key, $default = null)
- {
- if (is_null($key)) {
- return $array;
- }
- if (isset($array[$key])) {
- return $array[$key];
- }
- foreach (explode('.', $key) as $segment) {
- if (!is_array($array) || !array_key_exists($segment, $array)) {
- return value($default);
- }
- $array = $array[$segment];
- }
- return $array;
- }
- }
- if (!function_exists('array_has')) {
- /**
- * Check if an item exists in an array using "dot" notation.
- *
- * @param array $array
- * @param string $key
- * @return bool
- */
- function array_has($array, $key)
- {
- if (empty($array) || is_null($key)) {
- return false;
- }
- if (array_key_exists($key, $array)) {
- return true;
- }
- foreach (explode('.', $key) as $segment) {
- if (!is_array($array) || !array_key_exists($segment, $array)) {
- return false;
- }
- $array = $array[$segment];
- }
- return true;
- }
- }
- if (!function_exists('array_only')) {
- /**
- * Get a subset of the items from the given array.
- *
- * @param array $array
- * @param array|string $keys
- * @return array
- */
- function array_only($array, $keys)
- {
- return array_intersect_key($array, array_flip((array)$keys));
- }
- }
- if (!function_exists('array_pluck')) {
- /**
- * Pluck an array of values from an array.
- *
- * @param array $array
- * @param string $value
- * @param string $key
- * @return array
- */
- function array_pluck($array, $value, $key = null)
- {
- $results = array();
- foreach ($array as $item) {
- $itemValue = data_get($item, $value);
- // If the key is "null", we will just append the value to the array and keep
- // looping. Otherwise we will key the array using the value of the key we
- // received from the developer. Then we'll return the final array form.
- if (is_null($key)) {
- $results[] = $itemValue;
- } else {
- $itemKey = data_get($item, $key);
- $results[$itemKey] = $itemValue;
- }
- }
- return $results;
- }
- }
- if (!function_exists('array_pull')) {
- /**
- * Get a value from the array, and remove it.
- *
- * @param array $array
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function array_pull(&$array, $key, $default = null)
- {
- $value = get($array, $key, $default);
- forget($array, $key);
- return $value;
- }
- }
- if (!function_exists('array_set')) {
- /**
- * Set an array item to a given value using "dot" notation.
- *
- * If no key is given to the method, the entire array will be replaced.
- *
- * @param array $array
- * @param string $key
- * @param mixed $value
- * @return array
- */
- function array_set(&$array, $key, $value)
- {
- if (is_null($key)) {
- return $array = $value;
- }
- $keys = explode('.', $key);
- while (count($keys) > 1) {
- $key = array_shift($keys);
- // If the key doesn't exist at this depth, we will just create an empty array
- // to hold the next value, allowing us to create the arrays to hold final
- // values at the correct depth. Then we'll keep digging into the array.
- if (!isset($array[$key]) || !is_array($array[$key])) {
- $array[$key] = array();
- }
- $array =& $array[$key];
- }
- $array[array_shift($keys)] = $value;
- return $array;
- }
- }
- if (!function_exists('array_where')) {
- /**
- * Filter the array using the given Closure.
- *
- * @param array $array
- * @param \Closure $callback
- * @return array
- */
- function array_where($array, Closure $callback)
- {
- $filtered = array();
- foreach ($array as $key => $value) {
- if (call_user_func($callback, $key, $value)) {
- $filtered[$key] = $value;
- }
- }
- return $filtered;
- }
- }
- if (!function_exists('camel_case')) {
- /**
- * Convert a value to camel case.
- *
- * @param string $value
- * @return string
- */
- function camel_case($value)
- {
- static $camelCache = [];
- if (isset($camelCache[$value])) {
- return $camelCache[$value];
- }
- return $camelCache[$value] = lcfirst(studly($value));
- }
- }
- if (!function_exists('class_basename')) {
- /**
- * Get the class "basename" of the given object / class.
- *
- * @param string|object $class
- * @return string
- */
- function class_basename($class)
- {
- $class = is_object($class) ? get_class($class) : $class;
- return basename(str_replace('\\', '/', $class));
- }
- }
- if (!function_exists('class_uses_recursive')) {
- /**
- * Returns all traits used by a class, it's subclasses and trait of their traits
- *
- * @param string $class
- * @return array
- */
- function class_uses_recursive($class)
- {
- $results = [];
- foreach (array_merge([$class => $class], class_parents($class)) as $class) {
- $results += trait_uses_recursive($class);
- }
- return array_unique($results);
- }
- }
- if (!function_exists('data_get')) {
- /**
- * Get an item from an array or object using "dot" notation.
- *
- * @param mixed $target
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function data_get($target, $key, $default = null)
- {
- if (is_null($key)) {
- return $target;
- }
- foreach (explode('.', $key) as $segment) {
- if (is_array($target)) {
- if (!array_key_exists($segment, $target)) {
- return value($default);
- }
- $target = $target[$segment];
- } elseif ($target instanceof ArrayAccess) {
- if (!isset($target[$segment])) {
- return value($default);
- }
- $target = $target[$segment];
- } elseif (is_object($target)) {
- if (!isset($target->{$segment})) {
- return value($default);
- }
- $target = $target->{$segment};
- } else {
- return value($default);
- }
- }
- return $target;
- }
- }
- if (!function_exists('e')) {
- /**
- * Escape HTML entities in a string.
- *
- * @param string $value
- * @return string
- */
- function e($value)
- {
- return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
- }
- }
- if (!function_exists('ends_with')) {
- /**
- * Determine if a given string ends with a given substring.
- *
- * @param string $haystack
- * @param string|array $needles
- * @return bool
- */
- function ends_with($haystack, $needles)
- {
- foreach ((array)$needles as $needle) {
- if ((string)$needle === substr($haystack, -strlen($needle))) {
- return true;
- }
- }
- return false;
- }
- }
- if (!function_exists('head')) {
- /**
- * Get the first element of an array. Useful for method chaining.
- *
- * @param array $array
- * @return mixed
- */
- function head($array)
- {
- return reset($array);
- }
- }
- if (!function_exists('last')) {
- /**
- * Get the last element from an array.
- *
- * @param array $array
- * @return mixed
- */
- function last($array)
- {
- return end($array);
- }
- }
- if (!function_exists('object_get')) {
- /**
- * Get an item from an object using "dot" notation.
- *
- * @param object $object
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function object_get($object, $key, $default = null)
- {
- if (is_null($key) || trim($key) == '') {
- return $object;
- }
- foreach (explode('.', $key) as $segment) {
- if (!is_object($object) || !isset($object->{$segment})) {
- return value($default);
- }
- $object = $object->{$segment};
- }
- return $object;
- }
- }
- if (!function_exists('preg_replace_sub')) {
- /**
- * Replace a given pattern with each value in the array in sequentially.
- *
- * @param string $pattern
- * @param array $replacements
- * @param string $subject
- * @return string
- */
- function preg_replace_sub($pattern, &$replacements, $subject)
- {
- return preg_replace_callback($pattern, function () use (&$replacements) {
- return array_shift($replacements);
- }, $subject);
- }
- }
- if (!function_exists('snake_case')) {
- /**
- * Convert a string to snake case.
- *
- * @param string $value
- * @param string $delimiter
- * @return string
- */
- function snake_case($value, $delimiter = '_')
- {
- static $snakeCache = [];
- $key = $value . $delimiter;
- if (isset($snakeCache[$key])) {
- return $snakeCache[$key];
- }
- if (!ctype_lower($value)) {
- $value = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1' . $delimiter, $value));
- }
- return $snakeCache[$key] = $value;
- }
- }
- if (!function_exists('starts_with')) {
- /**
- * Determine if a given string starts with a given substring.
- *
- * @param string $haystack
- * @param string|array $needles
- * @return bool
- */
- function starts_with($haystack, $needles)
- {
- foreach ((array)$needles as $needle) {
- if ($needle != '' && strpos($haystack, $needle) === 0) {
- return true;
- }
- }
- return false;
- }
- }
- if (!function_exists('str_contains')) {
- /**
- * Determine if a given string contains a given substring.
- *
- * @param string $haystack
- * @param string|array $needles
- * @return bool
- */
- function str_contains($haystack, $needles)
- {
- foreach ((array)$needles as $needle) {
- if ($needle != '' && strpos($haystack, $needle) !== false) {
- return true;
- }
- }
- return false;
- }
- }
- if (!function_exists('str_finish')) {
- /**
- * Cap a string with a single instance of a given value.
- *
- * @param string $value
- * @param string $cap
- * @return string
- */
- function str_finish($value, $cap)
- {
- $quoted = preg_quote($cap, '/');
- return preg_replace('/(?:' . $quoted . ')+$/', '', $value) . $cap;
- }
- }
- if (!function_exists('str_is')) {
- /**
- * Determine if a given string matches a given pattern.
- *
- * @param string $pattern
- * @param string $value
- * @return bool
- */
- function str_is($pattern, $value)
- {
- if ($pattern == $value) {
- return true;
- }
- $pattern = preg_quote($pattern, '#');
- // Asterisks are translated into zero-or-more regular expression wildcards
- // to make it convenient to check if the strings starts with the given
- // pattern such as "library/*", making any string check convenient.
- $pattern = str_replace('\*', '.*', $pattern) . '\z';
- return (bool)preg_match('#^' . $pattern . '#', $value);
- }
- }
- if (!function_exists('str_limit')) {
- /**
- * Limit the number of characters in a string.
- *
- * @param string $value
- * @param int $limit
- * @param string $end
- * @return string
- */
- function str_limit($value, $limit = 100, $end = '...')
- {
- if (mb_strlen($value) <= $limit) {
- return $value;
- }
- return rtrim(mb_substr($value, 0, $limit, 'UTF-8')) . $end;
- }
- }
- if (!function_exists('str_random')) {
- /**
- * Generate a more truly "random" alpha-numeric string.
- *
- * @param int $length
- * @return string
- *
- * @throws \RuntimeException
- */
- function str_random($length = 16)
- {
- if (!function_exists('openssl_random_pseudo_bytes')) {
- throw new RuntimeException('OpenSSL extension is required.');
- }
- $bytes = openssl_random_pseudo_bytes($length * 2);
- if ($bytes === false) {
- throw new RuntimeException('Unable to generate random string.');
- }
- return substr(str_replace(array('/', '+', '='), '', base64_encode($bytes)), 0, $length);
- }
- }
- if (!function_exists('str_replace_array')) {
- /**
- * Replace a given value in the string sequentially with an array.
- *
- * @param string $search
- * @param array $replace
- * @param string $subject
- * @return string
- */
- function str_replace_array($search, array $replace, $subject)
- {
- foreach ($replace as $value) {
- $subject = preg_replace('/' . $search . '/', $value, $subject, 1);
- }
- return $subject;
- }
- }
- if (!function_exists('str_slug')) {
- /**
- * Generate a URL friendly "slug" from a given string.
- *
- * @param string $title
- * @param string $separator
- * @return string
- */
- function str_slug($title, $separator = '-')
- {
- $title = ascii($title);
- // Convert all dashes/underscores into separator
- $flip = $separator == '-' ? '_' : '-';
- $title = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $title);
- // Remove all characters that are not the separator, letters, numbers, or whitespace.
- $title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', mb_strtolower($title));
- // Replace all separator characters and whitespace by a single separator
- $title = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $title);
- return trim($title, $separator);
- }
- }
- if (!function_exists('ascii')) {
- /**
- * Transliterate a UTF-8 value to ASCII.
- *
- * @param string $value
- * @return string
- */
- function ascii($value)
- {
- foreach (charsArray() as $key => $val) {
- $value = str_replace($val, $key, $value);
- }
- return preg_replace('/[^\x20-\x7E]/u', '', $value);
- }
- }
- if (!function_exists('charsArray')) {
- /**
- * Returns the replacements for the ascii method.
- *
- * Note: Adapted from Stringy\Stringy.
- *
- * @see https://github.com/danielstjules/Stringy/blob/2.3.1/LICENSE.txt
- *
- * @return array
- */
- function charsArray()
- {
- static $charsArray;
- if (isset($charsArray)) {
- return $charsArray;
- }
- return $charsArray = [
- '0' => ['°', '₀', '۰'],
- '1' => ['¹', '₁', '۱'],
- '2' => ['²', '₂', '۲'],
- '3' => ['³', '₃', '۳'],
- '4' => ['⁴', '₄', '۴', '٤'],
- '5' => ['⁵', '₅', '۵', '٥'],
- '6' => ['⁶', '₆', '۶', '٦'],
- '7' => ['⁷', '₇', '۷'],
- '8' => ['⁸', '₈', '۸'],
- '9' => ['⁹', '₉', '۹'],
- 'a' => [
- 'à',
- 'á',
- 'ả',
- 'ã',
- 'ạ',
- 'ă',
- 'ắ',
- 'ằ',
- 'ẳ',
- 'ẵ',
- 'ặ',
- 'â',
- 'ấ',
- 'ầ',
- 'ẩ',
- 'ẫ',
- 'ậ',
- 'ā',
- 'ą',
- 'å',
- 'α',
- 'ά',
- 'ἀ',
- 'ἁ',
- 'ἂ',
- 'ἃ',
- 'ἄ',
- 'ἅ',
- 'ἆ',
- 'ἇ',
- 'ᾀ',
- 'ᾁ',
- 'ᾂ',
- 'ᾃ',
- 'ᾄ',
- 'ᾅ',
- 'ᾆ',
- 'ᾇ',
- 'ὰ',
- 'ά',
- 'ᾰ',
- 'ᾱ',
- 'ᾲ',
- 'ᾳ',
- 'ᾴ',
- 'ᾶ',
- 'ᾷ',
- 'а',
- 'أ',
- 'အ',
- 'ာ',
- 'ါ',
- 'ǻ',
- 'ǎ',
- 'ª',
- 'ა',
- 'अ',
- 'ا'
- ],
- 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ'],
- 'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'],
- 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ'],
- 'e' => [
- 'é',
- 'è',
- 'ẻ',
- 'ẽ',
- 'ẹ',
- 'ê',
- 'ế',
- 'ề',
- 'ể',
- 'ễ',
- 'ệ',
- 'ë',
- 'ē',
- 'ę',
- 'ě',
- 'ĕ',
- 'ė',
- 'ε',
- 'έ',
- 'ἐ',
- 'ἑ',
- 'ἒ',
- 'ἓ',
- 'ἔ',
- 'ἕ',
- 'ὲ',
- 'έ',
- 'е',
- 'ё',
- 'э',
- 'є',
- 'ə',
- 'ဧ',
- 'ေ',
- 'ဲ',
- 'ე',
- 'ए',
- 'إ',
- 'ئ'
- ],
- 'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ'],
- 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ'],
- 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ'],
- 'i' => [
- 'í',
- 'ì',
- 'ỉ',
- 'ĩ',
- 'ị',
- 'î',
- 'ï',
- 'ī',
- 'ĭ',
- 'į',
- 'ı',
- 'ι',
- 'ί',
- 'ϊ',
- 'ΐ',
- 'ἰ',
- 'ἱ',
- 'ἲ',
- 'ἳ',
- 'ἴ',
- 'ἵ',
- 'ἶ',
- 'ἷ',
- 'ὶ',
- 'ί',
- 'ῐ',
- 'ῑ',
- 'ῒ',
- 'ΐ',
- 'ῖ',
- 'ῗ',
- 'і',
- 'ї',
- 'и',
- 'ဣ',
- 'ိ',
- 'ီ',
- 'ည်',
- 'ǐ',
- 'ი',
- 'इ'
- ],
- 'j' => ['ĵ', 'ј', 'Ј', 'ჯ', 'ج'],
- 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', 'ک'],
- 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ'],
- 'm' => ['м', 'μ', 'م', 'မ', 'მ'],
- 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', 'ნ'],
- 'o' => [
- 'ó',
- 'ò',
- 'ỏ',
- 'õ',
- 'ọ',
- 'ô',
- 'ố',
- 'ồ',
- 'ổ',
- 'ỗ',
- 'ộ',
- 'ơ',
- 'ớ',
- 'ờ',
- 'ở',
- 'ỡ',
- 'ợ',
- 'ø',
- 'ō',
- 'ő',
- 'ŏ',
- 'ο',
- 'ὀ',
- 'ὁ',
- 'ὂ',
- 'ὃ',
- 'ὄ',
- 'ὅ',
- 'ὸ',
- 'ό',
- 'о',
- 'و',
- 'θ',
- 'ို',
- 'ǒ',
- 'ǿ',
- 'º',
- 'ო',
- 'ओ'
- ],
- 'p' => ['п', 'π', 'ပ', 'პ', 'پ'],
- 'q' => ['ყ'],
- 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ'],
- 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', 'ſ', 'ს'],
- 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', 'თ', 'ტ'],
- 'u' => [
- 'ú',
- 'ù',
- 'ủ',
- 'ũ',
- 'ụ',
- 'ư',
- 'ứ',
- 'ừ',
- 'ử',
- 'ữ',
- 'ự',
- 'û',
- 'ū',
- 'ů',
- 'ű',
- 'ŭ',
- 'ų',
- 'µ',
- 'у',
- 'ဉ',
- 'ု',
- 'ူ',
- 'ǔ',
- 'ǖ',
- 'ǘ',
- 'ǚ',
- 'ǜ',
- 'უ',
- 'उ'
- ],
- 'v' => ['в', 'ვ', 'ϐ'],
- 'w' => ['ŵ', 'ω', 'ώ', 'ဝ', 'ွ'],
- 'x' => ['χ', 'ξ'],
- 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ'],
- 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ'],
- 'aa' => ['ع', 'आ', 'آ'],
- 'ae' => ['ä', 'æ', 'ǽ'],
- 'ai' => ['ऐ'],
- 'at' => ['@'],
- 'ch' => ['ч', 'ჩ', 'ჭ', 'چ'],
- 'dj' => ['ђ', 'đ'],
- 'dz' => ['џ', 'ძ'],
- 'ei' => ['ऍ'],
- 'gh' => ['غ', 'ღ'],
- 'ii' => ['ई'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"\xE2\x80\x82",
- "\xE2\x80\x83",
- "\xE2\x80\x84",
- "\xE2\x80\x85",
- "\xE2\x80\x86",
- "\xE2\x80\x87",
- "\xE2\x80\x88",
- "\xE2\x80\x89",
- "\xE2\x80\x8A",
- "\xE2\x80\xAF",
- "\xE2\x81\x9F",
- "\xE3\x80\x80"
- ],
- ];
- }
- }
- if (!function_exists('studly_case')) {
- /**
- * Convert a value to studly caps case.
- *
- * @param string $value
- * @return string
- */
- function studly_case($value)
- {
- static $studlyCache = [];
- $key = $value;
- if (isset($studlyCache[$key])) {
- return $studlyCache[$key];
- }
- $value = ucwords(str_replace(array('-', '_'), ' ', $value));
- return $studlyCache[$key] = str_replace(' ', '', $value);
- }
- }
- if (!function_exists('title_case')) {
- /**
- * Convert a value to title case.
- *
- * @param string $value
- * @return string
- */
- function title_case($value)
- {
- return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
- }
- }
- if (!function_exists('trait_uses_recursive')) {
- /**
- * Returns all traits used by a trait and its traits
- *
- * @param string $trait
- * @return array
- */
- function trait_uses_recursive($trait)
- {
- $traits = class_uses($trait);
- foreach ($traits as $trait) {
- $traits += trait_uses_recursive($trait);
- }
- return $traits;
- }
- }
- if (!function_exists('value')) {
- /**
- * Return the default value of the given value.
- *
- * @param mixed $value
- * @return mixed
- */
- function value($value)
- {
- return $value instanceof Closure ? $value() : $value;
- }
- }
- if (!function_exists('with')) {
- /**
- * Return the given object. Useful for chaining.
- *
- * @param mixed $object
- * @return mixed
- */
- function with($object)
- {
- return $object;
- }
- }
- /**
- * Helper functions for the helper functions, that can still be used standalone
- */
- if (!function_exists('studly')) {
- /**
- * Convert a value to studly caps case.
- *
- * @param string $value
- * @return string
- */
- function studly($value)
- {
- static $studlyCache = [];
- $key = $value;
- if (isset($studlyCache[$key])) {
- return $studlyCache[$key];
- }
- $value = ucwords(str_replace(array('-', '_'), ' ', $value));
- return $studlyCache[$key] = str_replace(' ', '', $value);
- }
- }
- if (!function_exists('get')) {
- /**
- * Get an item from an array using "dot" notation.
- *
- * @param array $array
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- function get($array, $key, $default = null)
- {
- if (is_null($key)) {
- return $array;
- }
- if (isset($array[$key])) {
- return $array[$key];
- }
- foreach (explode('.', $key) as $segment) {
- if (!is_array($array) || !array_key_exists($segment, $array)) {
- return value($default);
- }
- $array = $array[$segment];
- }
- return $array;
- }
- }
- if (!function_exists('set')) {
- /**
- * Set an array item to a given value using "dot" notation.
- *
- * If no key is given to the method, the entire array will be replaced.
- *
- * @param array $array
- * @param string $key
- * @param mixed $value
- * @return array
- */
- function set(&$array, $key, $value)
- {
- if (is_null($key)) {
- return $array = $value;
- }
- $keys = explode('.', $key);
- while (count($keys) > 1) {
- $key = array_shift($keys);
- // If the key doesn't exist at this depth, we will just create an empty array
- // to hold the next value, allowing us to create the arrays to hold final
- // values at the correct depth. Then we'll keep digging into the array.
- if (!isset($array[$key]) || !is_array($array[$key])) {
- $array[$key] = array();
- }
- $array =& $array[$key];
- }
- $array[array_shift($keys)] = $value;
- return $array;
- }
- }
- if (!function_exists('dot')) {
- /**
- * Flatten a multi-dimensional associative array with dots.
- *
- * @param array $array
- * @param string $prepend
- * @return array
- */
- function dot($array, $prepend = '')
- {
- $results = array();
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $results = array_merge($results, dot($value, $prepend . $key . '.'));
- } else {
- $results[$prepend . $key] = $value;
- }
- }
- return $results;
- }
- }
- if (!function_exists('first')) {
- /**
- * Return the first element in an array passing a given truth test.
- *
- * @param array $array
- * @param \Closure $callback
- * @param mixed $default
- * @return mixed
- */
- function first($array, $callback, $default = null)
- {
- foreach ($array as $key => $value) {
- if (call_user_func($callback, $key, $value)) {
- return $value;
- }
- }
- return value($default);
- }
- }
- if (!function_exists('forget')) {
- /**
- * Remove one or many array items from a given array using "dot" notation.
- *
- * @param array $array
- * @param array|string $keys
- * @return void
- */
- function forget(&$array, $keys)
- {
- $original =& $array;
- foreach ((array)$keys as $key) {
- $parts = explode('.', $key);
- while (count($parts) > 1) {
- $part = array_shift($parts);
- if (isset($array[$part]) && is_array($array[$part])) {
- $array =& $array[$part];
- }
- }
- unset($array[array_shift($parts)]);
- // clean up after each pass
- $array =& $original;
- }
- }
- }
- if (!function_exists('bcrypt')) {
- /**
- * Password hash the given value.
- *
- * @param string $value
- * @param array $options
- * @return string
- *
- * @throws \RuntimeException
- */
- function bcrypt($value, $options = [])
- {
- $cost = isset($options['rounds']) ? $options['rounds'] : 10;
- $hashedValue = password_hash($value, PASSWORD_BCRYPT, ['cost' => $cost]);
- if ($hashedValue === false) {
- throw new RuntimeException('Bcrypt hashing not supported.');
- }
- return $hashedValue;
- }
- }
- if (!function_exists('tap')) {
- /**
- * Call the given Closure with the given value then return the value.
- *
- * @param mixed $value
- * @param callable $callback
- * @return mixed
- */
- function tap($value, $callback)
- {
- $callback($value);
- return $value;
- }
- }
- if (!function_exists('dd')) {
- /**
- * Dump the passed variables and end the script.
- *
- * @param mixed
- * @return void
- */
- function dd()
- {
- array_map(function ($x) {
- var_dump($x);
- }, func_get_args());
- die(1);
- }
- }
- if (!function_exists('data_fill')) {
- /**
- * Fill in data where it's missing.
- *
- * @param mixed $target
- * @param string|array $key
- * @param mixed $value
- * @return mixed
- */
- function data_fill(&$target, $key, $value)
- {
- return data_set($target, $key, $value, false);
- }
- }
- if (! function_exists('data_set')) {
- /**
- * Set an item on an array or object using dot notation.
- *
- * @param mixed $target
- * @param string|array $key
- * @param mixed $value
- * @param bool $overwrite
- * @return mixed
- */
- function data_set(&$target, $key, $value, $overwrite = true)
- {
- $segments = is_array($key) ? $key : explode('.', $key);
- if (($segment = array_shift($segments)) === '*') {
- if (! accessible($target)) {
- $target = [];
- }
- if ($segments) {
- foreach ($target as &$inner) {
- data_set($inner, $segments, $value, $overwrite);
- }
- } elseif ($overwrite) {
- foreach ($target as &$inner) {
- $inner = $value;
- }
- }
- } elseif (accessible($target)) {
- if ($segments) {
- if (! exists($target, $segment)) {
- $target[$segment] = [];
- }
- data_set($target[$segment], $segments, $value, $overwrite);
- } elseif ($overwrite || ! exists($target, $segment)) {
- $target[$segment] = $value;
- }
- } elseif (is_object($target)) {
- if ($segments) {
- if (! isset($target->{$segment})) {
- $target->{$segment} = [];
- }
- data_set($target->{$segment}, $segments, $value, $overwrite);
- } elseif ($overwrite || ! isset($target->{$segment})) {
- $target->{$segment} = $value;
- }
- } else {
- $target = [];
- if ($segments) {
- data_set($target[$segment], $segments, $value, $overwrite);
- } elseif ($overwrite) {
- $target[$segment] = $value;
- }
- }
- return $target;
- }
- /**
- * Determine whether the given value is array accessible.
- *
- * @param mixed $value
- * @return bool
- */
- function accessible($value)
- {
- return is_array($value) || $value instanceof ArrayAccess;
- }
- /**
- * Determine if the given key exists in the provided array.
- *
- * @param \ArrayAccess|array $array
- * @param string|int $key
- * @return bool
- */
- function exists($array, $key)
- {
- if ($array instanceof ArrayAccess) {
- return $array->offsetExists($key);
- }
- return array_key_exists($key, $array);
- }
- }
|