\O3PO_Utility

A collection of various utility functions.

Summary

Methods
Properties
Constants
check_orcid()
base_convert_arbitrary_precision()
remove_stopwords()
oxford_comma_implode()
make_slash_breakable_html()
valid_issn()
valid_email()
array_mean()
array_stddev()
array_median()
is_assoc()
$stop_words
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$stop_words

$stop_words : array

Array of stopwords.

Type

array — Array of stopwords.

Methods

check_orcid()

check_orcid(string  $orcid) 

Check that the given ORCID is well formated.

Verifies whether the given ORCID has a valid checksum.

Return true if the $orcid is a valid ORCID and otherwise a string describing why it is not valid.

Parameters

string $orcid

ORCID to check

base_convert_arbitrary_precision()

base_convert_arbitrary_precision(string  $str, integer  $frombase, integer  $tobase) 

Arbitrary precision base_convert().

Similar to PHPs base_convert() but with arbitrary precision. Taken from http://php.net/manual/en/function.base-convert.php.

Parameters

string $str

String representation of the number to covert.

integer $frombase

Base the input number is represented in.

integer $tobase

Base to with the number is to be converted.

remove_stopwords()

remove_stopwords(string  $text) 

Remove stopwords.

Removes the stopwords in static::stop_words from $text and tries to avoid the creation of double spaces.

Parameters

string $text

Text from which stopwords are to be removed.

oxford_comma_implode()

oxford_comma_implode(array  $array) 

Implode an array of words according to the oxford comma rule.

Parameters

array $array

Array of strings to be imploded with Oxford commas.

make_slash_breakable_html()

make_slash_breakable_html(string  $string) 

Make slashes breakable in text for html.

There is no way to break long lines with css or html that works consistently in all browsers. We are hence making long urls breakable by adding zero width space characters afert every /. This does not seem to have any adverse side-effects as the zero-width characters are ignored when a link text is copied and pasted.

Parameters

string $string

String in which slashes are to be made breakable.

valid_issn()

valid_issn(string  $issn) : boolean

Verify that an issn is well formed.

Parameters

string $issn

ISSN to be checked

Returns

boolean —

Whether $issn is well formed.

valid_email()

valid_email(string  $email) : boolean

Verify that an email is well formed.

Parameters

string $email

Email to be checked

Returns

boolean —

Whether $email is well formed.

array_mean()

array_mean(array  $array) : integer|float

Compute the mean

Parameters

array $array

Array for which to compute the mean.

Returns

integer|float —

Mean of the array.

array_stddev()

array_stddev(array  $array) : float

Compute the standard deviation

Parameters

array $array

Array for which to compute the standard deviation.

Returns

float —

Standard deviation of the array.

array_median()

array_median(array  $array) : float|integer

Compute the median.

Parameters

array $array

Array for which to compute the standard deviation.

Returns

float|integer —

Median of the array.

is_assoc()

is_assoc(array  $a) : \Whether

Test whether an array is associative or enumerated.

Parameters

array $a

Array to test.

Returns

\Whether —

the array is associative or not.