Creates a UUID version 3

@param Uuid|string $namespace A valid UUID namespace
@param string      $name      A unique string within the namespace

@return Uuid

@throws DomainException When the namespace is not a valid UUID
334619
protected static function uuid3($namespace, string $name): Uuid
    {
        if (!($namespace instanceof self)) {
            $namespace = static::parse($namespace);
        }

        $hash = md5($namespace->toBytes().$name);

        return static::fromUnformatted($hash, static::VERSION_MD5);
    }
965804
public static function create($rule, \SplPriorityQueue $namespaces = null)
    {
        if (!$rule) {
            return new NoneValidator();
        }

        if (class_exists($rule)) {
            return new $rule();
        }

        $namespaces = $namespaces ?: static::getNamespaces();

        foreach ($namespaces as $namespace) {
            $class = $namespace . '\\' . ucfirst($rule) . 'Validator';

            if (class_exists($class)) {
                return new $class();
            }
        }

        if (is_string($rule)) {
            return new RegexValidator($rule);
        }

        throw new \InvalidArgumentException(sprintf('Validator %s is not exists.', $rule));
    }
730453
public function createUserType($name)
    {
        $userType = new self();
        $userType->name = $name;
        if (!$userType->create()) {
            throw new UserTypeException($this->getMessages());
        }
        return $userType->id;
    }
1077097
public static function v3($namespace, $name)
    {
        if (!Validate::isValidUUID($namespace)) {
            return false;
        }

        // Get hexadecimal components of namespace
        $nhex = str_replace(array('-', '{', '}'), '', $namespace);

        // Binary Value
        $nstr = '';

        // Convert Namespace UUID to bits
        for ($i = 0; $i < strlen($nhex); $i += 2) {
            $nstr .= \chr(hexdec($nhex[$i] . $nhex[$i + 1]));
        }

        // Calculate hash value
        $hash = md5($nstr . $name);

        return sprintf('%08s-%04s-%04x-%04x-%12s',

            // 32 bits for "time_low"
            substr($hash, 0, 8),

            // 16 bits for "time_mid"
            substr($hash, 8, 4),

            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 3
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,

            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,

            // 48 bits for "node"
            substr($hash, 20, 12)
        );
    }
781566
public function createNamespace($name) {
		if (isset($this->_namespaces[$name])) {
			return $this->_namespaces[$name];
		}
		
		$namespace = new Bag($name);
		
		if ($this->hasLocator()) {
			$namespace->setDi($this->getLocator());
		}
		
		$this->_namespaces[$name] = $namespace;
		return $namespace;
	}
595201
public static function v3($namespace, $name)
    {
        if (!self::is_valid($namespace))
            return false;
        // Get hexadecimal components of namespace
        $nhex = str_replace(array('-', '{', '}'), '', $namespace);
        // Binary Value
        $nstr = '';
        // Convert Namespace UUID to bits
        for ($i = 0; $i < strlen($nhex); $i += 2) {
            $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
        }
        // Calculate hash value
        $hash = md5($nstr . $name);
        return sprintf('%08s-%04s-%04x-%04x-%12s',
            // 32 bits for "time_low"
            substr($hash, 0, 8),
            // 16 bits for "time_mid"
            substr($hash, 8, 4),
            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 3
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
            // 48 bits for "node"
            substr($hash, 20, 12)
        );
    }
1255814
public function setNamespace($namespace)
    {
        if (!is_string($namespace)) {
            throw new \InvalidArgumentException('The attribute namespace on the class Entity has to be string (' . gettype($namespace) . ('object' === gettype($namespace) ? ' ' . get_class($namespace) : '') . ' given).');
        }

        if (strlen($namespace) < 1) {
            throw new \InvalidArgumentException('On the attribute namespace, the length of the string ' . $namespace . ' is ' . strlen($namespace) . ' which is shorter than the minimum allowed (1).');
        }

        $this->namespace = $namespace;

        return $this;
    }
9625
public function ns($namespace, $defaultTTL = null)
    {
        $namespace = $this->id($namespace);
        $defaultTTL = $defaultTTL ?: $this->defaultTTL;
        return new Cache($this->backend, $namespace, $defaultTTL, $this->ttlVariation);
    }
598926
public function createNamespace(string $name): SessionInterface
    {
        $name = $this->getNamespacedKey($name);
        return new SessionNamespace($name, $this->session);
    }
630890
private static function generateVersion($namespace, $name, $version)
    {
        if (!self::isValid($namespace)) {
            return false;
        }

        $nhex = str_replace(array('-', '{', '}'), '', $namespace);
        $nstr = '';
        $len = strlen($nhex);

        for ($i = 0; $i < $len; $i += 2) {
            $nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
        }

        if ($version == 3) {
            $hash = md5($nstr.$name);
            $digit = 0x3000;
        } else {
            $hash = sha1($nstr.$name);
            $digit = 0x5000;
        }

        return sprintf('%08s-%04s-%04x-%04x-%12s',
            substr($hash, 0, 8),
            substr($hash, 8, 4),
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | $digit,
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
            substr($hash, 20, 12)
        );
    }
429371
public static function create($namespace = null, $name = null)
    {
        $bytes = self::generateBytes(16);
        $hex   = \bin2hex($bytes);

        return self::toString(self::uuidFromHashedName($hex, 4));
    }
1148607
public static function create($name) {
    $parts = explode('\\', $name);
    $name_node = new NameNode();
    foreach ($parts as $i => $part) {
      $part = trim($part);
      if ($i > 0) {
        $name_node->append(Token::namespaceSeparator());
      }
      if ($part !== '') {
        $name_node->append(Token::identifier($part));
      }
    }
    return $name_node;
  }
1249645
public function setNamespace($namespace)
    {
        if ($namespace === null || $namespace === '' || $namespace === '\\') {
            $this->namespace = null;

            return;
        }

        if ($namespace[0] === '\\') {
            $namespace = substr($namespace, 1);
        }

        if ($this->isNamespaceValid($namespace) !== true) {
            throw new InvalidArgumentException('Namespace name is not valid.');
        }

        $this->namespace = $namespace;
    }
229788
public function valueAlignmentForNamespace( $namespace, $name )
	{
		$prefix = "";

		switch ( $namespace )
		{
			case "http://xbrl.sec.gov/dei/2014-01-31":

				$prefix = "dei";
				break;

			case 'http://fasb.org/us-types/2014-01-31':
				$prefix = "us-types";
				break;

			default:
				return parent::valueAlignmentForNamespace( $namespace, $name );
		}

		$type = "$prefix:$name";

		switch ( $type )
		{
			case 'us-types:dateStringItemType':
			case 'dei:fiscalPeriodItemType':
			case 'dei:submissionTypeItemType':
			case 'dei:centralIndexKeyItemType':
			case 'dei:yesNoItemType':
			case 'dei:filerCategoryItemType':
			default:
				return "left";
		}

	}
814424
private function createAttributeValue($name, $value)
    {
        $factory = "create{$name}";

        if ($value instanceof JsonSerializable) {
            $value = $value->jsonSerialize();
        }

        $value = $this->{$factory}($value);

        if (!($value instanceof JsonSerializable || is_array($value))) {
            throw new DomainException('Invalid value factory');
        }

        return $value;
    }
1071254
public function create($namespace, $recipient, $expireIn = 300, $length = 6, $type = 'numeric')
    {
        $validCode = new ValidCode();
        $validCode->setNamespace($namespace);
        $validCode->setRecipient($recipient);
        $now = new \DateTime();
        $expiredAt = $now->add(new \DateInterval('PT' . $expireIn . 'S'));
        $validCode->setExpiredAt($expiredAt);
        $code = Str::random($length, $type);
        $validCode->setCode($code);
        $cacheKey = $this->getCacheKey($namespace, $recipient);
        $this->cache->save($cacheKey, $validCode, $expireIn);
        return $code;
    }
333475
public function registerNamespace($namespace, $directory)
    {
        $namespace = rtrim($namespace, self::NS_SEPARATOR). self::NS_SEPARATOR;
        $this->namespaces[$namespace] = $this->normalizeDirectory($directory);
        return $this;
    }