@param array $claims

@throws \InvalidArgumentException
515557
public function validateClaims(array $claims)
    {
        if ($this->requiredClaims) {
            $missing = array_diff_key(array_flip($this->requiredClaims), $claims);
            if (count($missing)) {
                throw new MissingClaimsException("Missing claims: " . implode(', ', $missing));
            }
        }
        if ($this->issuer && !isset($claims['iss'])) {
            throw new MissingClaimsException("Claim 'iss' is required");
        }
        if ($this->minIssueTime && !isset($claims['iat'])) {
            throw new MissingClaimsException("Claim 'iat' is required");
        }
        if (!empty($this->audience) && !isset($claims['aud'])) {
            throw new MissingClaimsException("Claim 'aud' is required");
        }
        if ((!isset($claims['sub']) || empty($claims['sub'])) && (!isset($claims['prn']) || empty($claims['prn']))) {
            throw new MissingClaimsException("Missing principle subject claim");
        }
        if (isset($claims['exp']) && $claims['exp'] + $this->issuerTimeLeeway < time()) {
            throw new InvalidTimeException("Token is expired by 'exp'");
        }
        if (isset($claims['iat']) && $claims['iat'] < ($this->minIssueTime + $this->issuerTimeLeeway)) {
            throw new InvalidTimeException("Server deemed your token too old");
        }
        if (isset($claims['nbf']) && ($claims['nbf'] - $this->issuerTimeLeeway) > time()) {
            throw new InvalidTimeException("Token not valid yet");
        }
        if (isset($claims['iss']) && $claims['iss'] !== $this->issuer) {
            throw new KeyTokenMismatchException("Issuer mismatch");
        }
        if (count($this->audience) && isset($claims['aud'])) {
            if (is_array($claims['aud'])) {
                foreach ($claims['aud'] as $claim) {
                    $this->validateAudience($claim);
                }
            } else {
                $this->validateAudience($claims['aud']);
            }
        }
    }
1351506
protected function write(array $record): void
    {
        if (!isset($record['formatted']) || 'string' !== gettype($record['formatted'])) {
            throw new \InvalidArgumentException('SqsHandler accepts only formatted records as a string');
        }

        $messageBody = $record['formatted'];
        if (strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {
            $messageBody = substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);
        }

        $this->client->sendMessage([
            'QueueUrl' => $this->queueUrl,
            'MessageBody' => $messageBody,
        ]);
    }
678476
public function setEntities(array $entities)
    {
        foreach ($entities as $entity) {
            if (! $entity instanceof AbstractEntity) {
                $message = sprintf(
                    'Expected an array of entities. Array contains element of type %s.',
                    gettype($entity)
                );

                throw new InvalidArgumentException($message);
            }
        }

        $this->entities = $entities;
    }
142720
public function addAssets(array $assets)
    {
        foreach ($assets as $asset) {
            if (!is_array($asset)) {
                throw new \InvalidArgumentException('Each element needs to be an array.');
            }
            $this->addAsset($asset);
        }
    }
804517
public function setClaims($claims)
    {
        $context = $this->_context;

        if ($claims && (!$context->type || !isset($claims[$context->type]))) {
            foreach ($claims as $claim => $value) {
                if (strlen($claim) > 3 && strrpos($claim, '_id', -3) !== false) {
                    $context->type = substr($claim, 0, -3);
                    break;
                }
            }
        }
        $context->claims = $claims;

        return $this;
    }
778262
protected function validateRecipients(array $recipients)
    {
        if (true == empty($recipients)) {
            throw new \InvalidArgumentException('Recipients list should not be empty');
        }

        foreach ($recipients as $recipient) {
            if (true == is_string($recipient) && $this->isValidMail($recipient)) {
                continue;
            }

            throw new \InvalidArgumentException(sprintf(
                'Given recipients list %s has invalid recipient %s',
                var_export($recipients, true),
                var_export($recipient, true)
            ));
        }
    }
558227
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->mean = Stats::mean($values);
    }
226329
public function setValues($values)
    {
        if ((null !== $values) && (false === is_array($values))) {
            if (false === ($values instanceof ArrayAccess)) {
                throw new InvalidArgumentException(
                    'The value of $values is not an array or an instance of ArrayAccess.'
                );
            }
        }

        $this->values = $values;
    }
779568
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->min = min($values);
        $this->max = max($values);
    }
1088707
public function setClaimsLocales(array $claimsLocales = null)
    {
        ValidationUtility::ensureNullOrArrayOfString('$claimsLocales', $claimsLocales);

        $this->claimsLocales = $claimsLocales;

        return $this;
    }
1027750
public function addRevisions( $revisions ) {
		if( !is_array( $revisions ) && !$revisions instanceof Revisions ) {
			throw new InvalidArgumentException( '$revisions needs to either be an array or a Revisions object' );
		}
		if( $revisions instanceof Revisions ) {
			$revisions = $revisions->toArray();
		}
		foreach( $revisions as $revision ) {
			$this->addRevision( $revision );
		}
	}
942931
public function ensureClaimValues(array $validateClaims)
    {
        foreach ($validateClaims as $claim => $value) {
            if (!isset($this->claims[$claim]) || $this->claims[$claim] !== $value) {
                return false;
            }
        }
        return true;
    }
540835
public function issue(Authenticatable $user, array $additionalCustomClaims = [])
    {
        // gets a new builder instance.
        $builder = $this->builder();

        // set the issued
        $builder->setIssuer($this->issuer);

        // set the subject.
        $builder->setSubject($user->getAuthIdentifier());

        // generate a unique id for the token, and set it to replicate as a header.
        $builder->setId($this->generateId(), true);

        // detect what time is it.
        $now = $this->now();

        // set issue date.
        $builder->setIssuedAt($now->timestamp);

        // set the token cannot be used before now.
        $builder->setNotBefore($now->timestamp);

        // calculate and set the expiration date for the token.
        $expiresAt = (clone $now)->addMinutes($this->ttl);
        $builder->setExpiration($expiresAt->timestamp);

        // created a custom claim that informs the limit time
        // for the token to be renewed.
        // the refresh limit is based on ttl + limit (grace period).
        $refreshLimit = (clone $now)->addMinutes($this->ttl + $this->refreshLimit);
        $builder->set('rli', $refreshLimit->timestamp);

        // loop through custom claims.
        foreach($additionalCustomClaims as $claim => $value) {
            // set custom claim.
            $builder->set($claim, $value);
        }

        // set user object default custom claims.
        if (method_exists($user, 'customJWTClaims')) {
            // call the methods.
            try {
                // call the custom claims method.
                $customClaims = (array) $user->customJWTClaims();

                // if the custom claims method returns a array.
                foreach($customClaims as $claim => $value) {
                    $builder->set($claim, $value);
                }
            } catch(\Exception $e) {
                // just continue since the custom claims should
                // not prevent the token of being issued.
            }
        }

        // get the signer.
        $signer = $this->signer();

        // sign the configure token.
        $builder->sign($signer, $this->secret);

        // gets the actual signed token as string.
        $token = (string) $builder->getToken();

        // returns the token.
        return $token;
    }
144023
public function setValue($value)
    {
        if (! $this->validate($value)) {
            throw new InvalidClaimException('Invalid value provided for claim "'.$this->getName().'": '.$value);
        }

        $this->value = $value;

        return $this;
    }
913631
public function setSubject($subject) {
    if (!is_string($subject)) {
      $error = sprintf("Subject given is not a string (Actual type: %s).",
               gettype($subject));
      throw new \InvalidArgumentException($error);
    }
    $this->message->setSubject($subject);
  }
1254277
public function setRoles(array $roles)
    {
        $this->roleIdentifiers = [];
        $this->roles = [];
        foreach ($roles as $role) {
            if (!$role instanceof Role) {
                throw new \InvalidArgumentException(sprintf('setRoles() only accepts an array of %s instances, given: "%s"', Role::class, gettype($role)), 1397125997);
            }
            $this->addRole($role);
        }
    }
890896
protected function ensureValidKeys($keys)
    {
        if (!is_array($keys) && !($keys instanceof \Traversable)) {
            throw new InvalidArgumentException('A cache key set must be either an array or a Traversable.');
        }

        foreach ($keys as $key) {
            $this->ensureValidKey($key);
        }
    }