Analyses a closure.

@param Model $model
The closure we want to analyse.

@throws \ReflectionException

@return string
The generated markup.
543664
public function process(Model $model)
    {
        $ref = new \ReflectionFunction($model->getData());

        $result = array();

        // Adding comments from the file.
        $result[static::META_COMMENT] =  $this->pool
            ->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Functions')
            ->getComment($ref);

        // Adding the sourcecode
        $highlight = $ref->getStartLine() -1;
        $result[static::META_SOURCE] = $this->pool->fileService->readSourcecode(
            $ref->getFileName(),
            $highlight,
            $highlight - 3,
            $ref->getEndLine() -1
        );

        // Adding the place where it was declared.
        $result[static::META_DECLARED_IN] = $this->pool->fileService->filterFilePath($ref->getFileName()) . "\n";
        $result[static::META_DECLARED_IN] .= 'in line ' . $ref->getStartLine();

        // Adding the namespace, but only if we have one.
        $namespace = $ref->getNamespaceName();
        if (empty($namespace) === false) {
            $result[static::META_NAMESPACE] = $namespace;
        }

        // Adding the parameters.
        $paramList = '';

        foreach ($ref->getParameters() as $key => $reflectionParameter) {
            ++$key;
            $paramList .=  $result[static::META_PARAM_NO . $key] = $this->pool
                ->codegenHandler
                ->parameterToString($reflectionParameter);
            // We add a comma to the parameter list, to separate them for a
            // better readability.
            $paramList .= ', ';
        }

        return $this->pool->render->renderExpandableChild(
            $model->setType(static::TYPE_CLOSURE)
                ->setNormal(static::UNKNOWN_VALUE)
                // Remove the ',' after the last char.
                ->setConnectorParameters(trim($paramList, ', '))
                ->setDomid($this->generateDomIdFromObject($model->getData()))
                ->setConnectorType(Connectors::METHOD)
                ->addParameter(static::PARAM_DATA, $result)
                ->injectCallback(
                    $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughMethodAnalysis')
                )
        );
    }
1261576
private function getModelAttributes(&$model)
	{
		$response 	= array();
		$reflection = new ReflectionClass($model);
		$properties = $reflection->getProperties(ReflectionProperty::IS_PROTECTED);

		foreach ($properties as $property)
			$response[$property->name] = $model[$property->name];

		return $response;
	}
1006027
protected static function modelEntityType($model)
    {
        if ($model instanceof QuestionInterface) {
            return self::ENTITY_QUESTION;
        } elseif ($model instanceof AnswerInterface) {
            return self::ENTITY_ANSWER;
        } else {
            $className = get_class($model);
            throw new UnknownClassException("Model class '{$className}' not supported");
        }
    }
25196
protected function getSoftDeleteMethods($model)
    {
        $traits = class_uses(get_class($model), true);
        if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
            $this->setMethod('forceDelete', 'bool|null', []);
            $this->setMethod('restore', 'bool|null', []);

            $this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
            $this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
        }
    }
16189
protected function _readMetaData($model)
    {
        $modelName = is_string($model) ? $model : get_class($model);

        if (!isset($this->_metadata[$modelName])) {
            $data = $this->read($modelName);
            if ($data !== false) {
                $this->_metadata[$modelName] = $data;
            } else {
                $modelInstance = is_string($model) ? new $model : $model;

                $data = $this->_di->getShared($modelInstance->getDb(true))->getMetadata($modelInstance->getSource(true));

                $this->_metadata[$modelName] = $data;
                $this->write($modelName, $data);
            }
        }

        return $this->_metadata[$modelName];
    }
995618
public function process(Model $model)
    {
        $data = $model->getData();

        // Check if this is a possible callback.
        // We are not going to analyse this further, because modern systems
        // do not use these anymore.
        if (function_exists($data) === true) {
            $model->setIsCallback(true);
        }

        // Checking the encoding.
        $encoding = $this->pool->encodingService->mbDetectEncoding($data);
        if ($encoding === false) {
            // Looks like we have a mixed encoded string.
            // We need to tell the dev!
            $length = $this->pool->encodingService->mbStrLen($data);
            $strlen = 'broken encoding ' . $length;
            $model->addToJson(static::META_ENCODING, 'broken');
        } else {
            // Normal encoding, nothing special here.
            $length = $strlen = $this->pool->encodingService->mbStrLen($data, $encoding);
        }

        if ($length > 20) {
            // Getting mime type from the string.
            // With larger strings, there is a good chance that there is
            // something interesting in there.
            $model->addToJson(static::META_MIME_TYPE, $this->bufferInfo->buffer($data));
        }

        // Check, if we are handling large string, and if we need to use a
        // preview (which we call "extra").
        // We also need to check for linebreaks, because the preview can not
        // display those.
        if ($length > 50 || strstr($data, PHP_EOL) !== false) {
            $cut = $this->pool->encodingService->encodeString(
                $this->pool->encodingService->mbSubStr($data, 0, 50)
            ) . static::UNKNOWN_VALUE;

            $data = $this->pool->encodingService->encodeString($data);

            $model->setHasExtra(true)
                ->setNormal($cut)
                ->setData($data);
        } else {
            $model->setNormal($this->pool->encodingService->encodeString($data));
        }

        return $this->pool->render->renderSingleChild(
            $model->setType(static::TYPE_STRING . $strlen)
                ->addToJson(static::META_LENGTH, $length)
        );
    }
906038
public static function model($model, $closure = null) {  
        $model = ucwords(strtolower($model));
        $request = KernelHttp::request();
        if($request->getModel() == $model) 
            self::explorer($model, $closure, $request);        
    }
574586
protected function deleteModel(Model $model)
    {
        $strategy = $this->getModelInformation()->deleteStrategy();

        if ( ! $strategy) {
            return $model->delete();
        }

        /** @var DeleteStrategyFactoryInterface $factory */
        $factory = app(DeleteStrategyFactoryInterface::class);
        $strategy = $factory->make($strategy);

        return $strategy->delete($model);
    }
1323938
protected function serializeModel($model)
    {
        if ($this->request->getIsHead()) {
            return null;
        }

        [$fields, $expand] = $this->getRequestedFields();
        return $model->toArray($fields, $expand);
    }
1016022
private function getId($model)
    {
        // Check to see if we can get an id via our defined methods
        foreach (self::$methods as $method) {
            if (method_exists($model, $method) && is_callable([$model, $method])) {
                return $model->$method();
            }
        }

        // Check to see if we can get an id via our defined properties
        foreach (self::$properties as $property) {
            if (isset($model->$property)) {
                return $model->$property;
            }
        }
    }
736053
public function update(Model $model)
    {
        $metadata = $model->getMetadata();
        $criteria = $this->getQuery()->getRetrieveCritiera($metadata, $model->getId());
        $update = $this->createUpdateObj($model);

        if (empty($update)) {
            return $model;
        }

        $this->getQuery()->executeUpdate($metadata, $model->getStore(), $criteria, $update);
        return $model;
    }
660456
public function generateDeleteForModel(AbstractModel $model)
    {
        $cacheData = $this->fetchCacheData($model);

        $strategy = new MySQLDeleteStrategy(
            $cacheData[self::TABLE_DATA_INDEX],
            $this->prepareModelData(
                $model,
                $cacheData[self::TABLE_DATA_INDEX]
            )
        );

        $strategy->setTransformer($this->paramTransformer);

        return [
            $strategy->generateSQLStatement(),
            $this->prepareModelDataForStatement($strategy->getPrimaryKeySet()),
            self::DELETE_QUERY
        ];
    }
381858
public static function determineModelClassNameQualified(string $model): string
    {
        $classNameModel = static::getModelClassNameQualifiedOrNull($model);

        if (is_null($classNameModel)) {
            throw new BunqException(self::ERROR_MODEL_NOT_DEFINED, [$model]);
        }

        return $classNameModel;
    }
13110
protected function getModel($model)
    {
        if ($model instanceof Model) {
            return $model;
        }

        if (!class_exists($model) || !is_string($model) || !is_subclass_of($model, Model::class)) {
            throw new \InvalidArgumentException("Invalid model [$model] !");
        }

        return new $model();
    }
425401
protected function getFactoryAttributes(Model $model)
    {
        // This package allows developers to specify attributes for single locales
        // in their factory definitions with the attribute:locale syntax,
        // but the Eloquent\FactoryBuilder's raw() method interprets them as regular attributes,
        // and if we were to make() the model and then call getAttribute() everytime,
        // such attributes would cause Translatable to run a query for each model instance.
        // We'll resort to binding a closure to the factory to get the defined states,
        // and pass them as custom attributes to raw().
        // This has the added bonus over make()->getAttributes() of delaying the calling
        // of any closure in factory definitions/states, allowing them to receive the model
        // with more attributes set and the inserted primary keys as arguments,
        // like the closure custom attributes passed to Populator.
        $factory = app(Eloquent\Factory::class);

        $states = $this->isTranslation($model) ? $this->translationStates : $this->states;

        $modelClass = get_class($model);

        $modelIsDefined = call_user_func(\Closure::bind(function () use ($modelClass) {
            return isset($this->definitions[$modelClass]);
        }, $factory, $factory));

        if (!$modelIsDefined) {
            // If the model is not defined in the factory and the developer didn't apply any state,
            // that means he doesn't need the factory for this model, so we'll return an empty array.
            if (!$states) {
                return [];
            }

            // If the model doesn't have a factory definition,
            // but the developer still wants to apply states,
            // we'll create a dummy definition of the model to allow it.
            $factory->define($modelClass, function () {
                return [];
            });
        }

        return $factory->raw($modelClass, $this->getStateAttributes($factory, $states, $modelClass));
    }
1232149
protected function checkModelType($model)
    {
        if (is_string($model)) {
            return $this->getTable($model);
        } elseif (is_object($model)) {
            return $this->getTable(get_class($model));
        }
    }
1324868
protected function determineRouteAction(Model $model)
    {
        $routeHelper = $this->getRouteHelper();

        $permissionPrefix = $routeHelper->getPermissionPrefixForModelSlug(
            $routeHelper->getRouteSlugForModelClass(get_class($model))
        );

        // Change the action to show if we don't have edit permissions
        if ( ! cms_auth()->can($permissionPrefix . 'edit')) {
            return 'show';
        }

        return 'edit';
    }