PDF rausgenommen
This commit is contained in:
19
msd2/phpBB3/vendor/bantu/ini-get-wrapper/LICENSE
vendored
Normal file
19
msd2/phpBB3/vendor/bantu/ini-get-wrapper/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Andreas Fischer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
15
msd2/phpBB3/vendor/bantu/ini-get-wrapper/composer.json
vendored
Normal file
15
msd2/phpBB3/vendor/bantu/ini-get-wrapper/composer.json
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "bantu/ini-get-wrapper",
|
||||
"type": "library",
|
||||
"description": "Convenience wrapper around ini_get()",
|
||||
"license": "MIT",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "bantu\\IniGetWrapper\\": "src/" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "bantu\\IniGetWrapper\\": "tests/" }
|
||||
}
|
||||
}
|
162
msd2/phpBB3/vendor/bantu/ini-get-wrapper/src/IniGetWrapper.php
vendored
Normal file
162
msd2/phpBB3/vendor/bantu/ini-get-wrapper/src/IniGetWrapper.php
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* (c) Andreas Fischer <git@andreasfischer.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace bantu\IniGetWrapper;
|
||||
|
||||
/**
|
||||
* Wrapper class around built-in ini_get() function.
|
||||
*
|
||||
* Provides easier handling of the different interpretations of ini values.
|
||||
*/
|
||||
class IniGetWrapper
|
||||
{
|
||||
/**
|
||||
* Simple wrapper around ini_get()
|
||||
* See http://php.net/manual/en/function.ini-get.php
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|string Null if configuration option does not exist.
|
||||
* The configuration option value (string) otherwise.
|
||||
*/
|
||||
public function get($varname)
|
||||
{
|
||||
$value = $this->getPhp($varname);
|
||||
return $value === false ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration option value as a trimmed string.
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|string Null if configuration option does not exist.
|
||||
* The configuration option value (string) otherwise.
|
||||
*/
|
||||
public function getString($varname)
|
||||
{
|
||||
$value = $this->get($varname);
|
||||
return $value === null ? null : trim($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets configuration option value as a boolean.
|
||||
* Interprets the string value 'off' as false.
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|bool Null if configuration option does not exist.
|
||||
* False if configuration option is disabled.
|
||||
* True otherwise.
|
||||
*/
|
||||
public function getBool($varname)
|
||||
{
|
||||
$value = $this->getString($varname);
|
||||
return $value === null ? null : $value && strtolower($value) !== 'off';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets configuration option value as an integer.
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|int|float Null if configuration option does not exist or is not numeric.
|
||||
* The configuration option value (integer or float) otherwise.
|
||||
*/
|
||||
public function getNumeric($varname)
|
||||
{
|
||||
$value = $this->getString($varname);
|
||||
return is_numeric($value) ? $value + 0 : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets configuration option value in bytes.
|
||||
* Converts strings like '128M' to bytes (integer or float).
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|int|float Null if configuration option does not exist or is not well-formed.
|
||||
* The configuration option value as bytes (integer or float) otherwise.
|
||||
*/
|
||||
public function getBytes($varname)
|
||||
{
|
||||
$value = $this->getString($varname);
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
// Already in bytes.
|
||||
return $value + 0;
|
||||
}
|
||||
|
||||
if (strlen($value) < 2 || strlen($value) < 3 && $value[0] === '-') {
|
||||
// Either a single character
|
||||
// or two characters where the first one is a minus.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Split string into numeric value and unit.
|
||||
$value_numeric = substr($value, 0, -1);
|
||||
if (!is_numeric($value_numeric)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (strtolower($value[strlen($value) - 1])) {
|
||||
case 'g':
|
||||
$value_numeric *= 1024;
|
||||
// no break
|
||||
case 'm':
|
||||
$value_numeric *= 1024;
|
||||
// no break
|
||||
case 'k':
|
||||
$value_numeric *= 1024;
|
||||
break;
|
||||
|
||||
default:
|
||||
// It's not already in bytes (and thus numeric)
|
||||
// and does not carry a unit.
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value_numeric;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets configuration option value as a list (array).
|
||||
* Converts comma-separated string into list (array).
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @return null|array Null if configuration option does not exist.
|
||||
* The configuration option value as a list (array) otherwise.
|
||||
*/
|
||||
public function getList($varname)
|
||||
{
|
||||
$value = $this->getString($varname);
|
||||
return $value === null ? null : explode(',', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a list contains a given element (string).
|
||||
*
|
||||
* @param string $varname The configuration option name.
|
||||
* @param string $needle The element to check whether it is contained in the list.
|
||||
* @return null|bool Null if configuration option does not exist.
|
||||
* Whether $needle is contained in the list otherwise.
|
||||
*/
|
||||
public function listContains($varname, $needle)
|
||||
{
|
||||
$list = $this->getList($varname);
|
||||
return $list === null ? null : in_array($needle, $list, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $varname The configuration option name.
|
||||
*/
|
||||
protected function getPhp($varname)
|
||||
{
|
||||
return ini_get($varname);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user