ArgumentCount
extends Exception
in package
Exception for when an incorrect number of arguments are passed to a method.
Typically, this exception is used when all arguments for a method are optional, but certain arguments need to be passed together, i.e. a method which can be called with no arguments or with two arguments, but not with one argument.
Along the same lines, this exception is also used if a method expects an array with a certain number of elements and the provided number of elements does not comply.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Create a new exception
- create() : ArgumentCount
- Create a new argument count exception with a standardized text.
- getData() : mixed
- Gives any relevant data
- getType() : string
- Like {@see \Exception::getCode()}, but a string code.
Properties
$data
Data associated with the exception
protected
mixed
$data
$type
Type of exception
protected
string
$type
Methods
__construct()
Create a new exception
public
__construct(string $message, string $type[, mixed $data = null ][, int $code = 0 ]) : mixed
Parameters
- $message : string
-
Exception message
- $type : string
-
Exception type
- $data : mixed = null
-
Associated data
- $code : int = 0
-
Exception numerical code, if applicable
create()
Create a new argument count exception with a standardized text.
public
static create(string $expected, int $received, string $type) : ArgumentCount
Parameters
- $expected : string
-
The argument count expected as a phrase. For example:
at least 2 arguments
orexactly 1 argument
. - $received : int
-
The actual argument count received.
- $type : string
-
Exception type.
Return values
ArgumentCountgetData()
Gives any relevant data
public
getData() : mixed
Tags
getType()
Like {@see \Exception::getCode()}, but a string code.
public
getType() : string