\XilyBase

The Xily Base class provides some basic features for all other Xily classes.

Summary

Methods
Properties
Constants
initValue()
initRequest()
equationBuild()
equationCheck()
strStripQuotes()
strStripBrackets()
strStripString()
strStripWhitespaces()
strStripInline()
strShorten()
strToFloat()
htmlDecode()
htmlEncode()
xmlChars()
createUID()
fileFormatDir()
fileRead()
fileReadByLine()
fileWrite()
fileRemoveDir()
fileCopyDir()
fileListDir()
fileGetExtension()
fileRename()
probe()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

initValue()

initValue(int|float|array|bool|object|string $mxtValue, string $strType, int|float|array|bool|object|string $mxtDefault) : int|float|array|bool|object|string

Initialize a variable value

Parameters

int|float|array|bool|object|string $mxtValue

Value to initialize

string $strType

Variable type

int|float|array|bool|object|string $mxtDefault

Default value

Returns

int|float|array|bool|object|string —

Initialized value

initRequest()

initRequest(string $strKey, mixed $mxtDefault)

Initializes a request variable

Parameters

string $strKey

Name of the variable

mixed $mxtDefault

Default value

equationBuild()

equationBuild(string $strFilter, bool $bolList) : array

Creates an array containing the tree parameters attribute, operator and value to express an equation. The method also aims to simplify the operator by narrowing them down to <, >, =, and !

Parameters

string $strFilter

The filter string, e.g "x >= 10"

bool $bolList

Returns a list of all equations

Returns

array —

['attribute', 'operator', 'value']

equationCheck()

equationCheck(string $strValue1, string $strValue2, string $strOperator) : bool

Checks, if an equation is correct

Parameters

string $strValue1

First parameter

string $strValue2

Second parameter

string $strOperator

Equation operator (==, !=, <, >, <=, >=)

Returns

bool

strStripQuotes()

strStripQuotes(string $strQuote) : string

Strips the quote symbols form a string

Parameters

string $strQuote

Returns

string

strStripBrackets()

strStripBrackets(string $strQuote) : string

Strips the brackets from the beginning and end of a string

Parameters

string $strQuote

Returns

string

strStripString()

strStripString(string $strText, string $strOpen, string $strClose, bool $bolStrict) : string

Strips defined chars from the beginning and the end of a string

Parameters

string $strText
string $strOpen
string $strClose
bool $bolStrict

Only strip symmetrical strings

Returns

string

strStripWhitespaces()

strStripWhitespaces(string $strText) : string

Strips all whitespaces from the beginning and end of a string

Parameters

string $strText

Returns

string

strStripInline()

strStripInline(string $strText, bool $bolLineBreaks) : string

Reduces a paragraph to one single line, removing all linebreaks, tabs and blank spaces

Parameters

string $strText
bool $bolLineBreaks

If set, also linebreaks are removed (otherwise only tabs and blank spaces)

Returns

string

strShorten()

strShorten(string $strText, int $numLength, bool $bolDots, bool $bolWords) : string

Shortens a string to a specified number of chars.

Parameters

string $strText
int $numLength
bool $bolDots

Puts three dots [...] at the end of the shortened string.

bool $bolWords

Respect single words when shortening a text.

Returns

string

strToFloat()

strToFloat(string $strNumber, bool $bolNegative) : float

Converts a formated string into a float

Parameters

string $strNumber

The formated number, e.g. "1,293.00 €"

bool $bolNegative

Support negative numbers

Returns

float

htmlDecode()

htmlDecode(string $strHTML, bool $bolBreak) : string

Converts a HTML string into a plain text string, decoding existing HTML special chars

Parameters

string $strHTML
bool $bolBreak

Also replace
linebreaks in regular linebreaks "\n"

Returns

string

htmlEncode()

htmlEncode(string $strText, string $bolBreak) : \Xily\unknown

Converts a regular string into HTML code, encoding HTML special chars.

Parameters

string $strText
string $bolBreak

If linebreak is true, the function will add
linebreaks

Returns

\Xily\unknown

xmlChars()

xmlChars(string $strRaw) : string

Encodes special XML characters

Parameters

string $strRaw

Returns

string

createUID()

createUID() : string

Creates a unique identifier

Returns

string

fileFormatDir()

fileFormatDir(string $strDirectory, string $strSlash) : string

Makes sure the directory ends with a slash

Parameters

string $strDirectory

The directory

string $strSlash

The slash format (default is DIRECTORY_SEPARATOR)

Returns

string

fileRead()

fileRead(string $strFile) : string|bool

Reads the contents of a file to a string

Parameters

string $strFile

The filename

Returns

string|bool

fileReadByLine()

fileReadByLine(string $strFile, \Xily\stirng $strFunction) : string

Reads the contents of a file to a string line by line and optionally calls a function for each line

Parameters

string $strFile

The filename

\Xily\stirng $strFunction

Name of the function to be called for each line

Returns

string —

The file contents

fileWrite()

fileWrite(string $strFile, string $strText, bool $bolModeAdd) : bool

Writes a string to a file

Parameters

string $strFile

The filename

string $strText

String to write

bool $bolModeAdd

Appends the string at the end of the file

Returns

bool

fileRemoveDir()

fileRemoveDir(string $strDirectory, bool $bolEmpty) : bool

Recursively removes a directory and the files and subdirectories contained in it

Parameters

string $strDirectory
bool $bolEmpty

Declaration of the directory to be empty

Returns

bool

fileCopyDir()

fileCopyDir(string $strDirectory, string $strDestination, bool $bolCreate) : bool

Recursively copies a directory and the files and subdirectories contained in it

Parameters

string $strDirectory
string $strDestination
bool $bolCreate

This option defines, if the whole directory should be copied or only its contents

Returns

bool

fileListDir()

fileListDir(string $strDirName, string $strFiletype) : array

Returns an array with the contents of a directory

Parameters

string $strDirName

The directory name

string $strFiletype

Filter for certain file extensions

Returns

array

fileGetExtension()

fileGetExtension(string $strFilename) : string

Returns the file extension

Parameters

string $strFilename

Filename

Returns

string

fileRename()

fileRename(string $strOldFileName, string $strNewFileName) : bool

Renames a file

Parameters

string $strOldFileName
string $strNewFileName

Returns

bool

probe()

probe(string $strSource, string $strMessage, int $intLevel) : bool

Echos a message, if modeDebug is active. This function can be very useful to place status messages in your functions, to gain some insights of what your program is doing.

Parameters

string $strSource

The function's name where the probe is placed

string $strMessage

The debug message

int $intLevel

Priority/Level of the message

Returns

bool —

Returns, whether the probe was echoed