Get a relationship value from a method.

@param  string  $method
@return mixed

@throws \LogicException
548700
protected function getRelationshipFromMethod($method)
	{
		$relations = $this->$method();

		if ( ! $relations instanceof Relation)
		{
			throw new LogicException('Relationship method must return an object of type '
				. 'Illuminate\Database\Eloquent\Relations\Relation');
		}

		return $this->relations[$method] = $relations->getResults();
	}
436416
protected function getEndpoint($method)
    {
        $endpoint = "me/email_verify";
        $nonce = $this->getArgument("nonce");
        if (!is_null($nonce)) {
            $endpoint .= "/$nonce";
            $this->delArgument("nonce");
        }
        return $endpoint;
    }
635010
protected function checkMethodExist($method)
    {
        if (!method_exists($this, $method)) {
            if ($this->application->isDebugMode()) {
                return $this->createResponse(
                    sprintf('Called undefined method: %s.', get_class($this).'::'.$method),
                    500
                );
            } else {
                throw new \LogicException(sprintf('Called undefined method: %s.', get_class($this).'::'.$method));
            }
        }

        return true;
    }
317067
public function getValue($object)
    {
        $get = 'get'.ucfirst($this->property);
        $has = 'has'.ucfirst($this->property);
        $is = 'is'.ucfirst($this->property);

        if (method_exists($object, $get)) {
            return $object->$get();
        }

        if (method_exists($object, $has)) {
            return $object->$has();
        }

        if (method_exists($object, $is)) {
            return $object->$is();
        }

        throw DeserializerLogicException::createMissingMethod(get_class($object), [$get, $has, $is]);
    }
276672
public function setMethods($methods)
    {
        if (is_string($methods)) {
            if (!isset(self::$validMethods[strtolower($methods)])) {
                throw new \LogicException(sprintf('Route method "%s" is invalid. Params expected "%s"', $methods, implode(', ', array_keys(self::$validMethods))));
            }
            $this->methods = array($methods);
        }
        
        if (is_array($methods)) {
            $this->methods = $methods;
        }
        
        return $this;
    }
463807
private function _sqlFromMethod($method)
    {
        if(!preg_match('/^(findBy|oneBy)(.*?)$/', $method, $m))
            throw new \BadMethodCallException("Unable to parse $method");

        // split on AND or OR and case boundries
        $sql = strtolower(preg_replace('/(?<=[a-z0-9\b])(Or|And)(?=[A-Z])/',' $1 ',$m[2]));

        // add parameter binds
        return preg_replace_callback('/\b([\w-]+)\b/', function($m) {
            return ($m[0] != 'or' && $m[0] != 'and') ? "`{$m[0]}`=?" : $m[0];
        }, $sql);
    }
579265
public function getRelationship($model, $name)
    {
        $method = $this->getRelationshipMethodName($name);

        if (method_exists($this, $method)) {
            $relationship = $this->$method($model);

            if ($relationship !== null && ! ($relationship instanceof Relationship)) {
                throw new LogicException('Relationship method must return null or an instance of Tobscure\JsonApi\Relationship');
            }

            return $relationship;
        }
    }
113948
public function getValue($offset = null)
    {
        if (null === $offset) {
            $offset = $this->offset;
        }

        $token = $this->getToken($offset);

        if (!isset(self::$hasValue[$token[0]])) {
            throw LogicException::create(
                'Token #%d (%d) is not expected to have a value.',
                $offset,
                $token[0]
            );
        }

        switch ($token[0]) {
            case DocLexer::T_FALSE:
                return false;
            case DocLexer::T_FLOAT:
                return (float) $token[1];
            case DocLexer::T_INTEGER:
                return (int) $token[1];
            case DocLexer::T_IDENTIFIER:
            case DocLexer::T_STRING:
                return $token[1];
            case DocLexer::T_TRUE:
                return true;
        }

        return null;
    }
1043963
protected function get($property) {
        $mapping = $this->dao()->getMapping();

        if (isset($mapping['properties'][$property]))
            return $this->getNonRelationValue($property);

        if (isset($mapping['relations'][$property]))
            return $this->getRelationValue($property);

        throw new RuntimeException('Not a mapped property "'.$property.'"');
    }
1250875
public function get_controller($method) {
        global $CFG, $DB;

        $this->ensure_isset(array('context', 'component', 'area'));

        // make sure the passed method is a valid plugin name
        if ('gradingform_'.$method !== clean_param('gradingform_'.$method, PARAM_COMPONENT)) {
            throw new moodle_exception('invalid_method_name', 'core_grading');
        }
        $available = $this->get_available_methods(false);
        if (!array_key_exists($method, $available)) {
            throw new moodle_exception('invalid_method_name', 'core_grading');
        }

        // get the current grading area record if it exists
        if (is_null($this->areacache)) {
            $this->areacache = $DB->get_record('grading_areas', array(
                'contextid' => $this->context->id,
                'component' => $this->component,
                'areaname'  => $this->area),
            '*', IGNORE_MISSING);
        }

        if ($this->areacache === false) {
            // no area record yet, create one
            $area = array(
                'contextid' => $this->context->id,
                'component' => $this->component,
                'areaname'  => $this->area);
            $areaid = $DB->insert_record('grading_areas', $area);
            // reload the cache
            $this->areacache = $DB->get_record('grading_areas', array('id' => $areaid), '*', MUST_EXIST);
        }

        require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php');
        $classname = 'gradingform_'.$method.'_controller';

        return new $classname($this->context, $this->component, $this->area, $this->areacache->id);
    }
226915
private static function _checkAndReturnMany($method, $value) 
    {
        $cls = get_called_class();
        if (array_key_exists($cls, self::$_has_many)
            && array_key_exists($method, self::$_has_many[$cls])
        ) {
            return self::_resolveHasMany($method, $value);
        }
    }
572368
public function getMethod($method)
    {
        $method = \strtoupper($method);

        if (!isset($this->methods[$method])) {
            throw new \Exception('Method not found');
        }

        return $this->methods[$method];
    }
732247
public function getMethodAttribute($method)
    {
        if (is_array($method)) {
            return $method;
        } else {
            if (is_string($method)) {
                $method = (integer)$method;
            }
        }

        return VerbsMask::maskToArray($method);
    }
38263
protected function getMethodConfigKey($method, $key)
    {
        if ($this->isMapMethod($method) && array_key_exists($key, $this->config[$method])) {
            return $this->config[$method][$key];
        }

        return null;
    }
141139
public function getMappedMethod($method)
    {
        // Check if the method called is provided in the mapping.
        if (!array_key_exists($method, self::$validatorMapping)) {
            throw new Exception(sprintf(
                'Mapping for method "%s" not found, make sure it exists in the mapping file.',
                $method
            ));
        }

        return self::$validatorMapping[$method];
    }
228984
protected function getApiInstance($method)
    {
        $gateway = Helper::className($this->getDriver());

        $class = "\\Shoperti\\PayMe\\Gateways\\{$gateway}\\".Helper::className($method);

        if (!class_exists($class)) {
            throw new BadMethodCallException("Undefined method [{$method}] called.");
        }

        return new $class($this->gateway);
    }
49946
protected function _getRelationshipValue($relationship)
    {
        if (!isset($this->_relatedObjects[$relationship])) {
            $rel = static::$_classRelationships[get_called_class()][$relationship];

            if ($rel['type'] == 'one-one') {
                if ($value = $this->_getFieldValue($rel['local'])) {
                    $this->_relatedObjects[$relationship] = $rel['class']::getByField($rel['foreign'], $value);
                
                    // hook relationship for invalidation
                    static::$_classFields[get_called_class()][$rel['local']]['relationships'][$relationship] = true;
                } else {
                    $this->_relatedObjects[$relationship] = null;
                }
            } elseif ($rel['type'] == 'one-many') {
                if (!empty($rel['indexField']) && !$rel['class']::fieldExists($rel['indexField'])) {
                    $rel['indexField'] = false;
                }
                
                $this->_relatedObjects[$relationship] = $rel['class']::getAllByWhere(
                    array_merge($rel['conditions'], [
                        $rel['foreign'] => $this->_getFieldValue($rel['local']),
                    ]),
                
                    [
                        'indexField' => $rel['indexField'],
                        'order' => $rel['order'],
                        'conditions' => $rel['conditions'],
                    ]
                );
                
                
                // hook relationship for invalidation
                static::$_classFields[get_called_class()][$rel['local']]['relationships'][$relationship] = true;
            } elseif ($rel['type'] == 'context-children') {
                if (!empty($rel['indexField']) && !$rel['class']::fieldExists($rel['indexField'])) {
                    $rel['indexField'] = false;
                }

                $conditions = array_merge($rel['conditions'], [
                    'ContextClass' => $rel['contextClass'],
                    'ContextID' => $this->_getFieldValue($rel['local']),
                ]);
            
                $this->_relatedObjects[$relationship] = $rel['class']::getAllByWhere(
                    $conditions,
            
                    [
                        'indexField' => $rel['indexField'],
                        'order' => $rel['order'],
                    ]
                );
                
                // hook relationship for invalidation
                static::$_classFields[get_called_class()][$rel['local']]['relationships'][$relationship] = true;
            } elseif ($rel['type'] == 'context-parent') {
                $className = $this->_getFieldValue($rel['classField']);
                $this->_relatedObjects[$relationship] = $className ? $className::getByID($this->_getFieldValue($rel['local'])) : null;
                
                // hook both relationships for invalidation
                static::$_classFields[get_called_class()][$rel['classField']]['relationships'][$relationship] = true;
                static::$_classFields[get_called_class()][$rel['local']]['relationships'][$relationship] = true;
            } elseif ($rel['type'] == 'many-many') {
                if (!empty($rel['indexField']) && !$rel['class']::fieldExists($rel['indexField'])) {
                    $rel['indexField'] = false;
                }
                
                // TODO: support indexField, conditions, and order
                
                $this->_relatedObjects[$relationship] = $rel['class']::getAllByQuery(
                    'SELECT Related.* FROM `%s` Link JOIN `%s` Related ON (Related.`%s` = Link.%s) WHERE Link.`%s` = %u AND %s',
                
                    [
                        $rel['linkClass']::$tableName,
                        $rel['class']::$tableName,
                        $rel['foreign'],
                        $rel['linkForeign'],
                        $rel['linkLocal'],
                        $this->_getFieldValue($rel['local']),
                        $rel['conditions'] ? join(' AND ', $rel['conditions']) : '1',
                    ]
                );
                
                // hook relationship for invalidation
                static::$_classFields[get_called_class()][$rel['local']]['relationships'][$relationship] = true;
            } elseif ($rel['type'] == 'history' && static::isVersioned()) {
                $this->_relatedObjects[$relationship] = $rel['class']::getRevisionsByID($this->getPrimaryKeyValue(), $rel);
            }
        }
        
        return $this->_relatedObjects[$relationship];
    }