OptionConverter
OptionConverter
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Methods summary
Modifier and Type | Method |
---|---|
public static string the | getSystemProperty ( string key , string def ) |
public static | toBooleanEx ( unknown value ) |
public static | toIntegerEx ( unknown value ) |
public static | toPositiveIntegerEx ( unknown value ) |
public static | toLevelEx ( unknown value ) |
public static integer | toFileSizeEx ( mixed value ) |
public static | toStringEx ( unknown value ) |
public static string | substConstants ( string string ) |
Methods in detail
-
getSystemProperty
string the public static getSystemProperty ( string key , string def )Read a predefined var. It returns a value referenced by $key</var> using this search criteria: - if $key is a constant then return it. Else - if $key is set in $_ENV then return it. Else - return $def.param
string key The key to search for.string def The default value to return.return
n2n\log4php\option\string the -
toBooleanEx
public static toBooleanEx ( unknown value ) -
toIntegerEx
public static toIntegerEx ( unknown value )Converts $value to integer, or throws an exception if not possible. Floats cannot be converted to integer. -
toPositiveIntegerEx
public static toPositiveIntegerEx ( unknown value )Converts $value to integer, or throws an exception if not possible. Floats cannot be converted to integer. -
toLevelEx
public static toLevelEx ( unknown value ) -
toFileSizeEx
integer public static toFileSizeEx ( mixed value )Converts a value to a valid file size (integer). Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc. The final value will be rounded to the nearest integer. Examples: - '100' => 100 - '100.12' => 100 - '100KB' => 102400 - '1.5MB' => 1572864param
mixed value File size (optionally with suffix).return
integer -
toStringEx
public static toStringEx ( unknown value )Converts a value to string, or throws an exception if not possible. Objects can be converted to string if they implement the magic __toString() method. -
substConstants
string public static substConstants ( string string )Performs value substitution for string options. An option can contain PHP constants delimited by '${@' and ''. E.g. for input string "some ${@FOO value", the method will attempt to substitute ${@FOO with the value of constant FOO if it exists. Therefore, if FOO is a constant, and it has value "bar", the resulting string will be "some bar value". If the constant is not defined, it will be replaced by an empty string, and the resulting string will be "some value".param
string string String on which to perform substitution.return
string