AloFramework Common Components 1.3 API
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • AloFramework
    • Common
  • PHP

Classes

  • Alo

Class Alo

Static common component container

Abstract
Namespace: AloFramework\Common
Author: Art a.molcanovas@gmail.com
Since:

1.3 getUniqid(), asciiRand(), isRegularRequest() added
1.2 getFingerprint(), isTraversable(), unXss() added
1.1 ifundefined() added


Located at Alo.php

Methods summary

public static boolean
# includeIfExists( string $path )

Includes a file if it exists

Includes a file if it exists

Parameters

$path
Path to the file

Returns

boolean
True if the file is found, false if not

Author

Art a.molcanovas@gmail.com
public static string
# asciiRand( integer $length, integer $subset = AloFramework\Common\Alo::ASCII_ALL )

Generates a string of random ASCII characters

Generates a string of random ASCII characters

Parameters

$length
The length of the string
$subset
Which subset to use - see class' ASCII_* constants

Returns

string

Author

Art a.molcanovas@gmail.com

Since

1.3
public static string
# getUniqid( string $hash = 'sha256', string $prefix = '', integer $entropy = 10000, boolean $rawOutput = false )

Generates a unique identifier

Generates a unique identifier

Parameters

$hash
Hash algorithm
$prefix
Prefix for the identifier
$entropy
Number of pseudo bytes used in entropy
$rawOutput
When set to true, outputs raw binary data. false outputs lowercase hexits.

Returns

string

Author

Art a.molcanovas@gmail.com

Since

1.3.3 Default $entropy value set to 10000, a warning is triggered if openssl_random_pseudo_bytes is unable to locate a cryptographically strong algorithm.
1.3


See

https://secure.php.net/manual/en/function.hash.php
https://secure.php.net/manual/en/function.openssl-random-pseudo-bytes.php

Codecoverageignore

public static boolean
# includeOnceIfExists( string $path )

include_once() a file if it exists

include_once() a file if it exists

Parameters

$path
Path to the file

Returns

boolean
True if the file is found, false if not

Author

Art a.molcanovas@gmail.com
public static boolean
# isCliRequest( )

Checks if we're dealing with a CLI request

Checks if we're dealing with a CLI request

Returns

boolean

Author

Art a.molcanovas@gmail.com
public static boolean
# isRegularRequest( )

Checks if the request is non-ajax and non-CLI

Checks if the request is non-ajax and non-CLI

Returns

boolean

Author

Art a.molcanovas@gmail.com

Since

1.3
public static mixed|null
# get( mixed & $var )

Returns $var if it's set, null if it's not

Returns $var if it's set, null if it's not

Parameters

$var
Reference to the variable

Returns

mixed|null
$var if it's set, null if it's not
public static mixed|null
# nullget( mixed & $var )

Returns $var if it's set and evaluates as true (a non-empty string, non-0 int etc), null otherwise

Returns $var if it's set and evaluates as true (a non-empty string, non-0 int etc), null otherwise

Parameters

$var
Reference to the variable

Returns

mixed|null
The var or null

Author

Art a.molcanovas@gmail.com
public static mixed
# ifnull( mixed & $var, mixed $planB, boolean $useNullget = false )

Returns $var if it's set $planB if it's not

Returns $var if it's set $planB if it's not

Parameters

$var
Reference to the main variable
$planB
What to return if $var isn't available
$useNullget

If set to true, will use self::nullget(), otherwise will use self::get() to determinewhether $var is set

Returns

mixed
$var if available, $planB if not

Author

Art a.molcanovas@gmail.com
public static mixed
# ifundefined( string $const, mixed $planB )

Returns the value of the constant with the name of $const if it's defined, $planB if it's not

Returns the value of the constant with the name of $const if it's defined, $planB if it's not

Parameters

$const
Constant name
$planB
What to return if $const isn't defined

Returns

mixed

Author

Art a.molcanovas@gmail.com

Since

1.1
public static boolean
# isAjaxRequest( )

Checks if the request was made via AJAX

Checks if the request was made via AJAX

Returns

boolean

Author

Art a.molcanovas@gmail.com
public static string
# getFingerprint( string $hashAlgo = 'sha256' )

Returns a hashed browser fingerprint

Returns a hashed browser fingerprint

Parameters

$hashAlgo
Hash algorithm to use

Returns

string

Author

Art a.molcanovas@gmail.com

Since

1.2
public static boolean
# isTraversable( mixed $input )

Checks if the variable is usable in a foreach loop

Checks if the variable is usable in a foreach loop

Parameters

$input
The variable

Returns

boolean

Author

Art a.molcanovas@gmail.com

Since

1.2
public static string|array|Traversable
# unXss( string|array|Traversable $input )

Protects the input from cross-site scripting attacks

Protects the input from cross-site scripting attacks

Parameters

$input
The scalar input, or an array/Traversable

Returns

string|array|Traversable

The escaped string. If an array or traversable was passed on, the input withall its applicable values escaped.

Author

Art a.molcanovas@gmail.com

Since

1.3.2 ENT_SUBSTITUTE added
1.2


Constants summary

integer ASCII_ALL

Defines the ascii charset subset as "the entire set"

Defines the ascii charset subset as "the entire set"

# 0
integer ASCII_ALPHANUM

Defines the ascii charset subset as "only alphanumeric"

Defines the ascii charset subset as "only alphanumeric"

# 1
integer ASCII_NONALPHANUM

Defines the ascii charset subset as "only non-alphanumeric"

Defines the ascii charset subset as "only non-alphanumeric"

# 2
AloFramework Common Components 1.3 API API documentation generated by ApiGen