X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fdrupal-driver%2Fsrc%2FDrupal%2FComponent%2FUtility%2FRandom.php;fp=vendor%2Fdrupal%2Fdrupal-driver%2Fsrc%2FDrupal%2FComponent%2FUtility%2FRandom.php;h=0000000000000000000000000000000000000000;hp=fb876414d6ba79d8387b951671ebada7ae333585;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/drupal/drupal-driver/src/Drupal/Component/Utility/Random.php b/vendor/drupal/drupal-driver/src/Drupal/Component/Utility/Random.php deleted file mode 100644 index fb876414d..000000000 --- a/vendor/drupal/drupal-driver/src/Drupal/Component/Utility/Random.php +++ /dev/null @@ -1,151 +0,0 @@ -strings[$str]); - } - if (!$continue && is_callable($validator)) { - // If the validator callback returns FALSE generate another random - // string. - $continue = !call_user_func($validator, $str); - } - } while ($continue); - - if ($unique) { - $this->strings[$str] = TRUE; - } - - return $str; - } - - /** - * Generates a random string containing letters and numbers. - * - * The string will always start with a letter. The letters may be upper or - * lower case. This method is better for restricted inputs that do not - * accept certain characters. For example, when testing input fields that - * require machine readable values (i.e. without spaces and non-standard - * characters) this method is best. - * - * @param int $length - * Length of random string to generate. - * @param bool $unique - * (optional) If TRUE ensures that the random string returned is unique. - * Defaults to FALSE. - * - * @return string - * Randomly generated string. - * - * @see \Drupal\Component\Utility\Random::string() - */ - public function name($length = 8, $unique = FALSE) { - $values = array_merge(range(65, 90), range(97, 122), range(48, 57)); - $max = count($values) - 1; - $counter = 0; - - do { - if ($counter == static::MAXIMUM_TRIES) { - throw new \RuntimeException('Unable to generate a unique random name'); - } - $str = chr(mt_rand(97, 122)); - for ($i = 1; $i < $length; $i++) { - $str .= chr($values[mt_rand(0, $max)]); - } - $counter++; - } while ($unique && isset($this->names[$str])); - - if ($unique) { - $this->names[$str] = TRUE; - } - - return $str; - } - - /** - * Generates a random PHP object. - * - * @param int $size - * The number of random keys to add to the object. - * - * @return \stdClass - * The generated object, with the specified number of random keys. Each key - * has a random string value. - */ - public function object($size = 4) { - $object = new \stdClass(); - for ($i = 0; $i < $size; $i++) { - $random_key = $this->name(); - $random_value = $this->string(); - $object->{$random_key} = $random_value; - } - return $object; - } - -}