Download the PHP package camelot/common without Composer
On this page you can find all versions of the php package camelot/common. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download camelot/common
More information about camelot/common
Files in camelot/common
Package common
Short Description Common utilities for all Camelot libraries
License MIT
Informations about the package common
Camelot Common
This library provides utility functions to help simplify menial tasks.
The Camelot team believes the PHP error reporting system is a mistake. Many built-in functions utilize it, leading to inconsistent results and head scratching.
This library provides some wrappers around some of these functions. Our code should always throw exceptions instead of triggering errors/warnings/notices (excluding deprecation warnings).
Table of Contents:
- Assert
- Deprecated
- Ini
- Json
- Serialization
- Str
Assert
Additional assertions built on Webmozart\Assert
isArrayAccessible
Throws InvalidArgumentException
if $value
is not an array or object
implementing ArrayAccess
.
isInstanceOfAny
Throws InvalidArgumentException
if $value
is not an instance of one of the
given classes/interfaces.
isIterable
Throws InvalidArgumentException
if $value
is not an iterable. Same as
isTraversable()
, just a better name.
Deprecated
Helper methods for triggering deprecation warnings.
warn
Shortcut for triggering a deprecation warning for something.
Examples:
method
Shortcut for triggering a deprecation warning for a method.
$suggest
can be a sentence describing what to use instead. Or it can be a
method name or class::method
which will be converted to a sentence.
$method
defaults to the method/function it was called from.
- If called from constructor, warning message says the class is deprecated.
- If called from magic method, warning message says the method/property called with is deprecated.
Example:
cls
Shortcut for triggering a deprecation warning for a class.
$suggest
can be a sentence describing what to use instead. Or it can be a
class name which will be converted to a sentence.
Examples:
Ini
Handles setting and retrieving values from PHP's configuration.
has
Checks whether the key exists.
getStr
Get a string value. The default is returned if the key does not exist or the value is empty.
getBool
Get a boolean value. False is returned if the key does not exist or the value is empty.
getNumeric
Get a numeric value. The default is returned if the key does not exist or the value is empty.
getBytes
Get a memory size value, such as memory_limit
, and convert it to an integer.
The default is returned if the key does not exist or the value is empty.
set
Set a new value for the given key.
Throws RuntimeException
if the key does not exist, it is not editable, or
something goes wrong.
Json
Handles JSON parsing/dumping with error handling.
parse
Parses JSON string to array or scalar.
Throws ParseException
if anything goes wrong.
We use seld/jsonlint
to determine why
the parsing failed and include it in the exception message.
dump
Dumps mixed to JSON string. Throws DumpException
if anything goes wrong.
If input contains invalid UTF-8 characters we try to convert these for you before failing.
test
Returns whether the string is valid JSON.
Serialization
Handles PHP serialization parsing/dumping with error handling.
parse
Parses PHP serialized string.
Throws ParseException
if a serialized class cannot be found or anything else
goes wrong.
Note: $options
parameter is ignored on PHP 5.
See unserialize()
for
details.
dump
Dumps anything to a PHP serialized string.
Throws DumpException
if the input is not serializable or anything else goes
wrong.
Str
Common string methods.
replaceFirst
Replaces the first occurrence of the $search text on the $subject.
replaceLast
Replaces the last occurrence of the $search text on the $subject.
removeFirst
Removes the first occurrence of the $search text on the $subject.
removeLast
Removes the last occurrence of the $search text on the $subject.
splitFirst
Splits a $subject on the $delimiter and returns the first part.
splitLast
Splits a $subject on the $delimiter and returns the last part.
endsWith
Returns whether the subjects ends with the search string.
className
Returns the class name without the namespace, of a string FQCN, or object.
humanize
Converts a string from camel case and snake case to a human readable string.
camelCase
Converts a string from snake case to camel case.
snakeCase
Converts a string from camel case to snake case.
All versions of common with dependencies
ext-json Version *
camelot/thrower Version ^1.0
seld/jsonlint Version ^1.4
webmozart/assert Version ^1.10