Determine if the given client can handle the given grant type.

@param  \Laravel\Passport\Client  $record
@param  string  $grantType
@return bool
548974
protected function handlesGrant($record, $grantType)
    {
        if (is_array($record->grant_types) && ! in_array($grantType, $record->grant_types)) {
            return false;
        }

        switch ($grantType) {
            case 'authorization_code':
                return ! $record->firstParty();
            case 'personal_access':
                return $record->personal_access_client;
            case 'password':
                return $record->password_client;
            case 'client_credentials':
                return ! empty($record->secret);
            default:
                return true;
        }
    }
1261835
public function handle(Collection $record)
    {
        $stringMessage = $this->formatter->format($record) . PHP_EOL;
        
        return (boolean) $this->writeStream($stringMessage);
    }
1372194
public function remove($record)
    {
        $params['index'] = $this->getName();
        $params['type'] = $record['type'];
        $params['id'] = $record['id'];

        self::getClient()->delete($params);
    }
316559
protected function requestAccessToken($grantType = 'client_credential')
    {
        $result = $this->httpGet(static::WECHAT_ACCESS_TOKEN_URL, [
            'appid' => $this->appId,
            'secret' => $this->appSecret,
            'grant_type' => 'client_credential'
        ]);
        if (isset($result['access_token'])) {
            $result['expire'] = $result['expires_in'] + (int)YII_BEGIN_TIME;
            return $result;
        }
        return false;
    }
529619
public static function update_plan(stdClass $record) {
        static::require_enabled();

        $plan = new plan($record->id);

        // Validate that the plan as it is can be managed.
        if (!$plan->can_manage()) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');

        } else if ($plan->get('status') == plan::STATUS_COMPLETE) {
            // A completed plan cannot be edited.
            throw new coding_exception('Completed plan cannot be edited.');

        } else if ($plan->is_based_on_template()) {
            // Prevent a plan based on a template to be edited.
            throw new coding_exception('Cannot update a plan that is based on a template.');

        } else if (isset($record->templateid) && $plan->get('templateid') != $record->templateid) {
            // Prevent a plan to be based on a template.
            throw new coding_exception('Cannot base a plan on a template.');

        } else if (isset($record->userid) && $plan->get('userid') != $record->userid) {
            // Prevent change of ownership as the capabilities are checked against that.
            throw new coding_exception('A plan cannot be transfered to another user');

        } else if (isset($record->status) && $plan->get('status') != $record->status) {
            // Prevent change of status.
            throw new coding_exception('To change the status of a plan use the appropriate methods.');

        }

        $plan->from_record($record);
        $plan->update();

        // Trigger updated event.
        \core\event\competency_plan_updated::create_from_plan($plan)->trigger();

        return $plan;
    }
1058280
public function map($record, $callbacks, $dryRun)
	{
		foreach ($callbacks as $callback)
		{
			if (is_callable($callback))
			{
				$record = $callback($record, $dryRun);
			}
		}

		return $record;
	}
1170821
public function setAllowedGrantTypes($allowedGrantTypes)
    {
        foreach ($allowedGrantTypes as $allowedGrantType) {
            if (!in_array($allowedGrantType, $this->availableGrantTypes)) {
                throw new \Exception('Unknown grant type ' . $allowedGrantType);
            }
        }
        $this->allowedGrantTypes = $allowedGrantTypes;
    }
1227496
public function getGrantType($grantType)
    {
        if (isset($this->grantTypes[$grantType])) {
            return $this->grantTypes[$grantType];
        }

        throw new Exception\InvalidGrantException($grantType);
    }
605630
public function isHandling(array $record)
    {
        if (empty($this->levels)) {
            return true;
        }

        return in_array($record['level'], $this->levels);
    }
156112
public function validate(EntityInterface $record) {
        $field = $this->getOption('field');
        $value = $record->readAttribute($field);
        if($value == '') {
            return true;
        } else {
            if(!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                $this->appendMessage($field . ' (Invalid Email): ' . $value, $field);
                return false;
            } else {
                return true;
            }
        }
    }
422111
public function pushRecord(Record $record)
    {
        $this->records[] = $record;

        if (!$record->getType()->isStdin() || $record->getContent()) {
            return;
        }

        return $this->buildRequest();
    }
243487
protected function isLimited(array $record)
    {
        if ($this->rateLimit <= 0) {
            return false;
        }

        $key = 'logger:lock:' . $this->identifyRecord($record);

        return !(bool) $this->redis->set($key, '', 'EX', $this->rateLimit, 'NX');
    }
307739
private function processRecord(array $record): ?int
    {
        $requestId = $record['requestId'];

        $content = 0 === $record['contentLength'] ? null : $record['contentData'];

        if (DaemonInterface::FCGI_BEGIN_REQUEST === $record['type']) {
            $this->processBeginRequestRecord($requestId, $content);
        } elseif (!isset($this->requests[$requestId])) {
            throw new ProtocolException('Invalid request id for record of type: '.$record['type']);
        } elseif (DaemonInterface::FCGI_PARAMS === $record['type']) {
            while (null !== $content && strlen($content) > 0) {
                $this->readNameValuePair($requestId, $content);
            }
        } elseif (DaemonInterface::FCGI_STDIN === $record['type']) {
            if (null !== $content) {
                fwrite($this->requests[$requestId]['stdin'], $content);
            } else {
                // Returns the status code
                return $this->dispatchRequest($requestId);
            }
        } elseif (DaemonInterface::FCGI_ABORT_REQUEST === $record['type']) {
            $this->endRequest($requestId);
        } else {
            throw new ProtocolException('Unexpected packet of type: '.$record['type']);
        }

        return null; // No status code to return
    }
40385
private static function injectGrants(AclAuthorization $acl, $grantType, array $rules)
    {
        foreach ($rules as $set) {
            if (! is_array($set) || ! isset($set['resource'])) {
                continue;
            }

            self::injectGrant($acl, $grantType, $set);
        }

        return $acl;
    }
374729
protected function evalSwitchTypeValue($record, $column, $value)
    {
        $contents = '';

        if ($value) {
            $contents = Lang::get('backend::lang.list.column_switch_true');
        }
        else {
            $contents = Lang::get('backend::lang.list.column_switch_false');
        }

        return $contents;
    }
4628
protected static function handler_from_record($record) {
        $classname = $record->classname;
        if (strpos($classname, '\\') !== 0) {
            $classname = '\\' . $classname;
        }
        if (!class_exists($classname)) {
            return false;
        }

        $handler = new $classname;
        if (isset($record->id)) {
            $handler->set_id($record->id);
        }
        $handler->set_component($record->component);

        // Overload fields which can be modified.
        if (isset($record->defaultexpiration)) {
            $handler->set_defaultexpiration($record->defaultexpiration);
        }

        if (isset($record->validateaddress)) {
            $handler->set_validateaddress($record->validateaddress);
        }

        if (isset($record->enabled)) {
            $handler->set_enabled($record->enabled);
        }

        return $handler;
    }
805242
public function doesRecordNeedUpdate(GedcomRecord $record): bool
    {
        $gedcom = $record->gedcom();

        return preg_match('/^1 SEX F/m', $gedcom) && preg_match('/^1 NAME /m', $gedcom) && $this->surnamesToAdd($record);
    }