/usr/share/php/ApiGen/Configuration/Configuration.php is in php-apigen 4.1.2-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | <?php
/**
* This file is part of the ApiGen (http://apigen.org)
*
* For the full copyright and license information, please view
* the file license.md that was distributed with this source code.
*/
namespace ApiGen\Configuration;
use ApiGen\Configuration\ConfigurationOptions as CO;
use Nette;
use Nette\Utils\Strings;
/**
* @method Configuration onOptionsResolve(array $config)
*/
class Configuration extends Nette\Object
{
const GROUPS_AUTO = 'auto';
const GROUPS_NAMESPACES = 'namespaces';
const GROUPS_PACKAGES = 'packages';
/**
* @var array
*/
public $onOptionsResolve = [];
/**
* @var array
*/
private $options = [];
/**
* @var ConfigurationOptionsResolver
*/
private $configurationOptionsResolver;
public function __construct(ConfigurationOptionsResolver $configurationOptionsResolver)
{
$this->configurationOptionsResolver = $configurationOptionsResolver;
}
/**
* @return array
*/
public function resolveOptions(array $options)
{
$options = $this->unsetConsoleOptions($options);
$this->options = $options = $this->configurationOptionsResolver->resolve($options);
$this->onOptionsResolve($options);
return $options;
}
/**
* @param string $name
* @return mixed|NULL
*/
public function getOption($name)
{
if (isset($this->getOptions()[$name])) {
return $this->getOptions()[$name];
}
return NULL;
}
/**
* @return array
*/
public function getOptions()
{
if ($this->options === NULL) {
$this->resolveOptions([]);
}
return $this->options;
}
/**
* @param int $namespaceCount
* @param int $packageCount
* @return bool
*/
public function areNamespacesEnabled($namespaceCount, $packageCount)
{
if ($this->getOption(CO::GROUPS) === self::GROUPS_NAMESPACES) {
return TRUE;
}
if ($this->getOption(CO::GROUPS) === self::GROUPS_AUTO && ($namespaceCount > 0 || $packageCount === 0)) {
return TRUE;
}
return FALSE;
}
/**
* @param bool $areNamespacesEnabled
* @return bool
*/
public function arePackagesEnabled($areNamespacesEnabled)
{
if ($this->getOption(CO::GROUPS) === self::GROUPS_PACKAGES) {
return TRUE;
} elseif ($this->getOption(CO::GROUPS) === self::GROUPS_AUTO && ($areNamespacesEnabled === FALSE)) {
return TRUE;
}
return FALSE;
}
/**
* @return string
*/
public function getZipFileName()
{
$webalizedTitle = Strings::webalize($this->getOption(CO::TITLE), NULL, FALSE);
return ($webalizedTitle ? '-' : '') . 'API-documentation.zip';
}
/**
* @return array
*/
private function unsetConsoleOptions(array $options)
{
unset($options[CO::CONFIG], $options['help'], $options['version'], $options['quiet']);
return $options;
}
}
|