public function run($bRemoveComment = true) { $sCurrentLine = ''; $aInstructionList = array(); foreach (preg_split("/((\r?\n)|(\r\n?))/", $this->sSelectedContent) as $line) { if (empty($line) || !Arr::in($this->nonAtom, substr($line, 0, 1))) { continue; } else { if ($bRemoveComment && strpos($line, ';') !== false) { $sCurrentLine .= strstr($line, ';', true); if (empty($sCurrentLine)) { continue; } } else { $sCurrentLine .= $line; } } if (substr_count($sCurrentLine, '(') !== substr_count($sCurrentLine, ')')) { continue; } try { // Util::var_dump($this->tokenize(trim($sCurrentLine))); echo '<br /><br />'; $aResult = $this->parse($this->tokenize(trim($sCurrentLine))); $aInstructionList[] = count($aResult) === 1 ? Arr::first($aResult) : $aResult; } catch (Exception $e) { echo 'Exception for : ' . '<br />'; Util::var_dump($sCurrentLine); } $sCurrentLine = ''; } return $aInstructionList; }
public static function loadConfiguration($sKey) { $aSegment = explode('.', $sKey); if (Arr::size($aSegment) > 0) { $sConfigName = Arr::first($aSegment); if (!isset(self::$aConfiguration[$sConfigName])) { self::initConfiguration(); $aTmpConfig = array(); // Common config $sCommonConfigPath = self::$sRealRootPath . RELATIVE_PATH_ROOT_TO_CONFIG . FOLDER_CONFIG_GLOBAL . $sConfigName . '.php'; if (Filesystem::exists($sCommonConfigPath)) { $aTmpConfig = (require $sCommonConfigPath); } // Env config $sCurrentEnvironment = self::getEnvironment(); $sConfigEnvironmentPath = self::$sRealRootPath . RELATIVE_PATH_ROOT_TO_CONFIG . $sCurrentEnvironment . '/' . $sConfigName . '.php'; if (Filesystem::exists($sConfigEnvironmentPath)) { $aTmpConfig = array_merge($aTmpConfig, require $sConfigEnvironmentPath); } self::$aConfiguration[$sConfigName] = $aTmpConfig; } } }
/** * Return the first element in an array passing a given truth test. * * @param array $array * @param \Closure $callback * @param mixed $default * @return mixed */ function array_first($array, $callback, $default = null) { return Arr::first($array, $callback, $default); }
/** * Get the first item from the collection. * * @param callable|null $callback * @param mixed $default * @return mixed */ public function first(callable $callback = null, $default = null) { return Arr::first($this->items, $callback, $default); }