public static function getAvailableKey() { while (true) { $length = rand(4, 6); $key = MyStringGenerator::createRandomString($length); $img = self::getImageByKey($key); if ($img == null) { return $key; } } }
private function getAvailableKey() { while (true) { $length = rand(4, 6); $key = MyStringGenerator::createRandomString($length); $img = $this->findOneBy(array('key' => $key)); if ($img == null) { return $key; } } }