Set the identity of the resource.

@throws \RuntimeException if the resource identity has already been set.
19922
public function setResourceIdentity(ResourceIdentity $identity): void
    {
        if ($this->resourceIdentity !== null) {
            throw new RuntimeException('The resource identity has already been set.');
        }

        $this->resourceIdentity = $identity;
    }
766440
public function setIdentifier(string $identifier): void
	{
		if(!in_array($identifier, ['email', 'username', 'id']))
		{
			throw new InvalidArgumentException(vsprintf('Invalid identifier [ %s ].', [$identifier]));
		}

		$this->identifier = $identifier;
	}
505951
public function setIdentifier($identifier)
    {
        if (is_string($identifier) === false || empty($identifier) === true) {
            throw new InvalidArgumentException(
                "The 'identifier' argument must be a non-empty string."
            );
        }
        
        $this->identifier = $identifier;
    }
930494
public function buildIdentity($identityData)
    {
        $class = $this->getConfig('identityClass');

        if (is_callable($class)) {
            $identity = $class($identityData);
        } else {
            $identity = new $class($identityData);
        }

        if (!($identity instanceof IdentityInterface)) {
            throw new RuntimeException(sprintf(
                'Object `%s` does not implement `%s`',
                get_class($identity),
                IdentityInterface::class
            ));
        }

        return $identity;
    }
347786
private function setSource()
    {
        if ($this->type == self::$DEFAULT_TYPE) {
            if (strlen($this->src) > 0)
                $this->setAttribute("src", $this->src);
        }

        if ($this->type == self::$URLDATA_TYPE) {
            $this->setAttribute("src", $this->getURLData());
        }

        if ($this->type == self::$DYNAMIC_TYPE) {
            $this->setAttribute("src", $this->owner->getURLNode() . "::" . $this->id . ':' . time() . '&binary=true');
        }
    }
394872
public function setIdentifier(Identifier $identifier)
    {
        if ($this->identifier !== null) {
            //TODO: throw exception
        }

        $this->identifier = $identifier;

        return $this;
    }
828462
public static function setIdentifierName(string $identifier): void
    {
        if (empty($identifier)) {
            throw new InvalidArgumentException("Identifier shouldn't be empty.");
        } elseif (\in_array($identifier, ['password'])) {
            throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!");
        }

        static::$identifier = $identifier;
    }
1237073
public function toEntity(
        $entity,
        ResourceTransformer $resourceTransformer,
        PropertyResolver $propertyResolver,
        PropertySetter $propertySetter,
        EntityFactory $factory,
        Context $context
    ) {

    }
508790
public function setDatatableId($id)
    {
        if (!array_key_exists($id, self::$instances)) {
            self::$instances[$id] = $this;
        } else {
            throw new \Exception('Identifer already exists');
        }

        return $this;
    }
849571
public function initialize()
    {
        if ( ! isset($this->authenticator)) {
            throw new \RuntimeException('Aegis is missing an authentication authenticator.');
        }

        if ( ! isset($this->storage)) {
            throw new \RuntimeException('Aegis is missing a persistent storage engine.');
        }

        // Set inital token to be anonymous until proven otherwise
        $this->setToken(new AnonymousToken());

        // Attempt to read token from persistent storage
        $token = $this->storage->read();

        // Re-authenticate stored token
        if ($token instanceof TokenInterface) {
            $result = $this->authenticate($token);
        }

        $this->initialized = true;

        return $this;
    }
949093
public function setResourceType(ResourceType $resourceType)
    {
        $this->iteratorName = '$' . $resourceType->getName();
        $this->resourceType = $resourceType;
    }
757998
public function setIdentifier($identifier)
    {
        if ($this->identifier && $this->identifier !== $identifier) {
            throw new MappingException('Cannot map the identifier to more than one property');
        }

        $this->identifier = $identifier;
    }
563064
public function setOwner( $userName )
	{
		if( !$userName )
			throw new InvalidArgumentException( 'No User Name given.' );
		if( !file_exists( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
#		if( !$this->isOwner() )
#			throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' );
		if( !$this->isWritable( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
		if( !@chOwn( $this->fileName, $userName ) )
			throw new RuntimeException( 'Only a superuser can change file owner' );
	}
948773
public static function set($name, $value)
    {
        $coID = Coroutine::getuid();
        if(!isset(static::$context[$coID]))
        {
            throw new \RuntimeException('set context data failed, current context is not found');
        }
        static::$context[$coID][$name] = $value;
    }
403943
public function setContext($context)
    {
        $contexts = array(self::CONTEXT_CREDITCARD, self::CONTEXT_TOKEN);
        if (!in_array($context, $contexts)) {
            throw new RuntimeException(
                sprintf("Invalid validation context '%s'", $context)
            );
        }

        $this->context = $context;
    }
1280061
public function claimUsedResourceIdentifier(ResourceInterface $resource) {
		if ($resource->getResource()->hasIdentification() === false) {
			throw new InputException('can not validate resource without identifier, set type and id first');
		}
		
		$resourceKey = $resource->getResource()->getIdentificationKey();
		if (isset($this->usedResourceIdentifiers[$resourceKey]) === false) {
			$this->usedResourceIdentifiers[$resourceKey] = true;
			return;
		}
		
		throw new DuplicateException('can not have multiple resources with the same identification');
	}
833317
public function run(): void
    {
        if ('' === (string)$this->catName) {
            throw new \RuntimeException('You must call setCatName before running this action');
        }
        if ('' === (string)$this->name) {
            throw new \RuntimeException('You must call setName before running this action');
        }
        $this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
    }