getOption('constants')) { return; } $category = $input->getOption('user') ? 'user' : $input->getOption('category'); $label = $category ? ucfirst($category) . ' Constants' : 'Constants'; $constants = $this->prepareConstants($this->getConstants($category)); if (empty($constants)) { return; } $ret = array(); $ret[$label] = $constants; return $ret; } /** * Get defined constants. * * Optionally restrict constants to a given category, e.g. "date". * * @param string $category * * @return array */ protected function getConstants($category = null) { if (!$category) { return get_defined_constants(); } $consts = get_defined_constants(true); return isset($consts[$category]) ? $consts[$category] : array(); } /** * Prepare formatted constant array. * * @param array $constants * * @return array */ protected function prepareConstants(array $constants) { // My kingdom for a generator. $ret = array(); $names = array_keys($constants); natcasesort($names); foreach ($names as $name) { if ($this->showItem($name)) { $ret[$name] = array( 'name' => $name, 'style' => self::IS_CONSTANT, 'value' => $this->presentRef($constants[$name]), ); } } return $ret; } }