Parses the content of the file separating the errors into a single array.

@param  string  $content
@param  string  $allowedEnvironment
@param  array   $allowedLevel

@return array
762005
protected function parseLog($content, $allowedEnvironment = null, $allowedLevel = [])
    {
        $log = [];

        $parsed = $this->parser->parseLogContent($content);

        extract($parsed, EXTR_PREFIX_ALL, 'parsed');

        if (empty($parsed_headerSet)) {
            return $log;
        }

        $needReFormat = in_array('Next', $parsed_headerSet);
        $newContent   = null;

        foreach ($parsed_headerSet as $key => $header) {
            if (empty($parsed_dateSet[$key])) {
                $parsed_dateSet[$key]  = $parsed_dateSet[$key-1];
                $parsed_envSet[$key]   = $parsed_envSet[$key-1];
                $parsed_levelSet[$key] = $parsed_levelSet[$key-1];
                $header                = str_replace("Next", $parsed_headerSet[$key-1], $header);
            }

            $newContent .= $header.' '.$parsed_bodySet[$key];

            if ((empty($allowedEnvironment) || $allowedEnvironment == $parsed_envSet[$key]) && $this->levelable->filter($parsed_levelSet[$key], $allowedLevel)) {
                $log[] = [
                    'environment' => $parsed_envSet[$key],
                    'level'       => $parsed_levelSet[$key],
                    'date'        => $parsed_dateSet[$key],
                    'file_path'   => $this->getCurrentLogPath(),
                    'header'      => $header,
                    'body'        => $parsed_bodySet[$key]
                ];
            }
        }

        if ($needReFormat) {
            file_put_contents($this->getCurrentLogPath(), $newContent);
        }

        return $log;
    }
791859
public static function check($filename, array $allowedExtension)
    {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);

        if (empty($ext)) {
            return false;
        }

        return in_array($ext, $allowedExtension);
    }
936535
public function setAllowedHosts($allowedHosts)
    {
        if (is_string($allowedHosts)) {
            $allowedHosts = preg_split('/ *, */', $allowedHosts);
        }
        $this->allowedHosts = $allowedHosts;
        return $this;
    }
432805
private function guardLevelBoundaries($levelValue)
    {
        if ($levelValue < static::MIN_LEVEL) {
            throw new Exceptions\MinLevelUnderflow(
                'Level has to be at least ' . self::MIN_LEVEL . ', got ' . $levelValue
            );
        }
        if ($levelValue > static::MAX_LEVEL) {
            throw new Exceptions\MaxLevelOverflow(
                'Level can not be greater than ' . self::MAX_LEVEL . ', got ' . $levelValue
            );
        }
    }
1354888
public function parseRelease(&$content)
	{
		$release = new Release;
		$types = [];
		$lastType = '';
		$nameSet = false;

		$line = current($content);
		while ($line !== false)
		{
			$line = ltrim($line);

			if ($this->startsWith($line, '###'))
			{
				$type = $this->trimHashes($line);
				$types[$type] = [];
				$lastType = $type;
			}
			elseif ($nameSet &&
				$this->startsWith($line, '##') ||
				$this->startsWith($line, '[')
			)
			{
				prev($content);
				break;
			}
			elseif ($this->startsWith($line, '##'))
			{
				$this->handleName($release, $line);
				$nameSet = true;
			}
			else
			{
				$change = ltrim($line, "\t\n\r\0\x0B -");

				if ($change !== '')
				{
					$types[$lastType][] = $change;
				}
			}

			$line = next($content);
		}

		$release->setAllChanges($types);
		return $release;
	}
184572
private function parseHeaders($headerContent)
    {
        $headers = [];
        $headerParts = preg_split('/\\R/s', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
        foreach ($headerParts as $headerPart) {
            if (strpos($headerPart, ':') === false) {
                continue;
            }

            [$headerName, $headerValue] = explode(':', $headerPart, 2);
            $headerName = strtolower(trim($headerName));
            $headerValue = trim($headerValue);

            if (strpos($headerValue, ';') === false) {
                $headers[$headerName] = $headerValue;
            } else {
                $headers[$headerName] = [];
                foreach (explode(';', $headerValue) as $part) {
                    $part = trim($part);
                    if (strpos($part, '=') === false) {
                        $headers[$headerName][] = $part;
                    } else {
                        [$name, $value] = explode('=', $part, 2);
                        $name = strtolower(trim($name));
                        $value = trim(trim($value), '"');
                        $headers[$headerName][$name] = $value;
                    }
                }
            }
        }

        return $headers;
    }
393229
protected function parseMessageFromRequest($content)
    {
        $content = strval($content);

        $arrayable = json_decode($content, true);
        if (json_last_error() === JSON_ERROR_NONE) {
            return $arrayable;
        }

        if (!$this->encryptor) {
            throw new RuntimeException('Safe mode Encryptor is necessary, please use Guard::setEncryptor(Encryptor $encryptor) set the encryptor instance.');
        }

        $message = $this->encryptor->decryptMsg(
            $this->request->get('msg_signature'),
            $this->request->get('nonce'),
            $this->request->get('timestamp'),
            $content
        );

        return $message;
    }
774657
public function parse($content)
    {
        if (strpos($content, '@ORM') === false) {
            return null;
        }

        if (preg_match(self::PATTERN, $content, $matches)) {
            return (new \SplFixedArray(2))->fromArray([$matches[1], $matches[2]]);
        }

        return null;
    }
1221354
public function parse($modelId, $rawConfig, $allowEmpty = false) {
        $config = json_decode($rawConfig, true);

        if (!is_null($config)) {
            $this->_validate($config, $allowEmpty);
            return $config;
        } else throw new Exception("The {$modelId} configuration file contains invalid JSON. Don't forget the double quotes around array keys and string-like values. Or use jsonlint.com to validate your file.");
    }
795428
public static function fromMethodFailure(array $allowedMethods)
    {
        $matchResult = new self();
        $matchResult->type = 'methodFailure';
        $matchResult->allowedMethods = $allowedMethods;
        return $matchResult;
    }
495277
public function validate(APILimitationValue $limitationValue): array
    {
        $validationErrors = array();
        $existingLanguages = $this->persistenceLanguageHandler->loadListByLanguageCodes(
            $limitationValue->limitationValues
        );
        $missingLanguages = array_diff(
            $limitationValue->limitationValues,
            array_keys($existingLanguages)
        );
        if (!empty($missingLanguages)) {
            $validationErrors[] = new ValidationError(
                "limitationValues[] => '%languageCodes%' translation(s) do not exist",
                null,
                [
                    'languageCodes' => implode(', ', $missingLanguages),
                ]
            );
        }

        return $validationErrors;
    }
1126243
public function methodNotAllowed(string $requestMethod, array $allowedMethods): Error
    {
        $this->status->methodNotAllowed($allowedMethods);
        return Error::methodNotAllowed($requestMethod, $allowedMethods);
    }
652904
public function getAcceptableContentTypes()
    {
        if (null !== $this->acceptableContentTypes) {
            return $this->acceptableContentTypes;
        }

        return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all());
    }
912108
final public static function allowedParams (array $allowedParams=[], string $option) : array
	{
		$allowedArray 	= [];
		$option 		= static::checkGlobal($option);
		foreach ($allowedParams as $param) $allowedArray[$param] = $option[$param] ?? NULL;
		return $allowedArray;
	}
552173
public static function parseFile($templateFilePath, $variables = array(), $allowDebug = true)
    {
        ob_start();

        // Print debug info in the the logs
        // only when Strata is running as the development
        // environment.
        if (Strata::isDev() && $allowDebug) {
            $app = Strata::app();
            $startedAt = microtime(true);

            // Print in the html as a comment
            $partialFilePath = defined('ABSPATH') ?
                str_replace(dirname(dirname(ABSPATH)), "", $templateFilePath) :
                $templateFilePath;
        }

        extract($variables);
        include $templateFilePath;

        if (Strata::isDev() && $allowDebug) {
            $executionTime = microtime(true) - $startedAt;
            $timer = sprintf(" (Done in %s seconds)", round($executionTime, 4));
            $app->log($partialFilePath . $timer, "<yellow>Template</yellow>");
        }

        return ob_get_clean();
    }
151426
public function parseLogContent($content)
    {
        $headerSet = $dateSet = $envSet = $levelSet = $bodySet = [];

        $pattern = "/^" .self::LOG_DATE_PATTERN. "\s" .self::LOG_ENVIRONMENT_PATTERN. "\." .self::LOG_LEVEL_PATTERN. "\:|Next/m";

        preg_match_all($pattern, $content, $matchs);

        if (is_array($matchs)) {
            $bodySet = array_map('ltrim', preg_split($pattern, $content));

            if (empty($bodySet[0]) && count($bodySet) > count($matchs[0])) {
                array_shift($bodySet);
            }

            $headerSet = $matchs[0];
            $dateSet   = $matchs[1];
            $envSet    = $matchs[2];
            $levelSet  = $matchs[3];
            $bodySet   = $bodySet;
        }

        return compact('headerSet', 'dateSet', 'envSet', 'levelSet', 'bodySet');
    }
544790
private function getRestrictedContentTypes(array $hasAccess): array
    {
        $restrictedContentTypesIds = $this->permissionChecker->getRestrictions($hasAccess, ContentTypeLimitation::class);
        if (empty($restrictedContentTypesIds)) {
            return [];
        }

        $restrictedContentTypesIdentifiers = [];
        $restrictedContentTypes = $this->contentTypeService->loadContentTypeList($restrictedContentTypesIds);
        foreach ($restrictedContentTypes as $restrictedContentType) {
            $restrictedContentTypesIdentifiers[] = $restrictedContentType->identifier;
        }

        return $restrictedContentTypesIdentifiers;
    }