updated backend
This commit is contained in:
parent
1fea0f4fe7
commit
11521c2339
3459 changed files with 72735 additions and 168535 deletions
60
pfosten/vendor/webmozart/assert/README.md
vendored
60
pfosten/vendor/webmozart/assert/README.md
vendored
|
|
@ -3,19 +3,15 @@ Webmozart Assert
|
|||
|
||||
[](https://travis-ci.org/webmozart/assert)
|
||||
[](https://ci.appveyor.com/project/webmozart/assert/branch/master)
|
||||
[](https://scrutinizer-ci.com/g/webmozart/assert/?branch=master)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
[](https://www.versioneye.com/php/webmozart:assert/1.2.0)
|
||||
|
||||
Latest release: [1.2.0](https://packagist.org/packages/webmozart/assert#1.2.0)
|
||||
|
||||
PHP >= 5.3.9
|
||||
|
||||
This library contains efficient assertions to test the input and output of
|
||||
your methods. With these assertions, you can greatly reduce the amount of coding
|
||||
needed to write a safe implementation.
|
||||
|
||||
All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if
|
||||
All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if
|
||||
they fail.
|
||||
|
||||
FAQ
|
||||
|
|
@ -27,21 +23,21 @@ This library is heavily inspired by Benjamin Eberlei's wonderful [assert package
|
|||
but fixes a usability issue with error messages that can't be fixed there without
|
||||
breaking backwards compatibility.
|
||||
|
||||
This package features usable error messages by default. However, you can also
|
||||
This package features usable error messages by default. However, you can also
|
||||
easily write custom error messages:
|
||||
|
||||
```
|
||||
Assert::string($path, 'The path is expected to be a string. Got: %s');
|
||||
```
|
||||
|
||||
In [beberlei/assert], the ordering of the `%s` placeholders is different for
|
||||
every assertion. This package, on the contrary, provides consistent placeholder
|
||||
In [beberlei/assert], the ordering of the `%s` placeholders is different for
|
||||
every assertion. This package, on the contrary, provides consistent placeholder
|
||||
ordering for all assertions:
|
||||
|
||||
* `%s`: The tested value as string, e.g. `"/foo/bar"`.
|
||||
* `%2$s`, `%3$s`, ...: Additional assertion-specific values, e.g. the
|
||||
minimum/maximum length, allowed values, etc.
|
||||
|
||||
|
||||
Check the source code of the assertions to find out details about the additional
|
||||
available placeholders.
|
||||
|
||||
|
|
@ -74,11 +70,11 @@ If you create an employee with an invalid ID, an exception is thrown:
|
|||
|
||||
```php
|
||||
new Employee('foobar');
|
||||
// => InvalidArgumentException:
|
||||
// => InvalidArgumentException:
|
||||
// The employee ID must be an integer. Got: string
|
||||
|
||||
new Employee(-10);
|
||||
// => InvalidArgumentException:
|
||||
// => InvalidArgumentException:
|
||||
// The employee ID must be a positive integer. Got: -10
|
||||
```
|
||||
|
||||
|
|
@ -111,6 +107,7 @@ Method | Description
|
|||
`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` a at least one class on the array of classes
|
||||
`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class
|
||||
`isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array
|
||||
`uniqueValues($values, $message = '')` | Check that the given array contains unique values
|
||||
|
||||
### Comparison Assertions
|
||||
|
||||
|
|
@ -146,6 +143,8 @@ Method | Description
|
|||
`startsWithLetter($value, $message = '')` | Check that a string starts with a letter
|
||||
`endsWith($value, $suffix, $message = '')` | Check that a string has a suffix
|
||||
`regex($value, $pattern, $message = '')` | Check that a string matches a regular expression
|
||||
`notRegex($value, $pattern, $message = '')` | Check that a string does not match a regular expression
|
||||
`unicodeLetters($value, $message = '')` | Check that a string contains Unicode letters only
|
||||
`alpha($value, $message = '')` | Check that a string contains letters only
|
||||
`digits($value, $message = '')` | Check that a string contains digits only
|
||||
`alnum($value, $message = '')` | Check that a string contains letters and digits only
|
||||
|
|
@ -156,6 +155,10 @@ Method | Description
|
|||
`maxLength($value, $max, $message = '')` | Check that a string has at most a certain number of characters
|
||||
`lengthBetween($value, $min, $max, $message = '')` | Check that a string has a length in the given range
|
||||
`uuid($value, $message = '')` | Check that a string is a valid UUID
|
||||
`ip($value, $message = '')` | Check that a string is a valid IP (either IPv4 or IPv6)
|
||||
`ipv4($value, $message = '')` | Check that a string is a valid IPv4
|
||||
`ipv6($value, $message = '')` | Check that a string is a valid IPv6
|
||||
`email($value, $message = '')` | Check that a string is a valid e-mail address
|
||||
`notWhitespaceOnly($value, $message = '')` | Check that a string contains at least one non-whitespace character
|
||||
|
||||
### File Assertions
|
||||
|
|
@ -174,6 +177,7 @@ Method | Description
|
|||
----------------------------------------------------- | --------------------------------------------------
|
||||
`classExists($value, $message = '')` | Check that a value is an existing class name
|
||||
`subclassOf($value, $class, $message = '')` | Check that a class is a subclass of another
|
||||
`interfaceExists($value, $message = '')` | Check that a value is an existing interface name
|
||||
`implementsInterface($value, $class, $message = '')` | Check that a class implements an interface
|
||||
`propertyExists($value, $property, $message = '')` | Check that a property exists in a class/object
|
||||
`propertyNotExists($value, $property, $message = '')` | Check that a property does not exist in a class/object
|
||||
|
|
@ -186,10 +190,15 @@ Method | Description
|
|||
-------------------------------------------------- | ------------------------------------------------------------------
|
||||
`keyExists($array, $key, $message = '')` | Check that a key exists in an array
|
||||
`keyNotExists($array, $key, $message = '')` | Check that a key does not exist in an array
|
||||
`validArrayKey($key, $message = '')` | Check that a value is a valid array key (int or string)
|
||||
`count($array, $number, $message = '')` | Check that an array contains a specific number of elements
|
||||
`minCount($array, $min, $message = '')` | Check that an array contains at least a certain number of elements
|
||||
`maxCount($array, $max, $message = '')` | Check that an array contains at most a certain number of elements
|
||||
`countBetween($array, $min, $max, $message = '')` | Check that an array has a count in the given range
|
||||
`isList($array, $message = '')` | Check that an array is a non-associative list
|
||||
`isNonEmptyList($array, $message = '')` | Check that an array is a non-associative list, and not empty
|
||||
`isMap($array, $message = '')` | Check that an array is associative and has strings as keys
|
||||
`isNonEmptyMap($array, $message = '')` | Check that an array is associative and has strings as keys, and is not empty
|
||||
|
||||
### Function Assertions
|
||||
|
||||
|
|
@ -215,6 +224,27 @@ assertion only if it the value is not `null`:
|
|||
Assert::nullOrString($middleName, 'The middle name must be a string or null. Got: %s');
|
||||
```
|
||||
|
||||
### Extending Assert
|
||||
|
||||
The `Assert` class comes with a few methods, which can be overridden to change the class behaviour. You can also extend it to
|
||||
add your own assertions.
|
||||
|
||||
#### Overriding methods
|
||||
|
||||
Overriding the following methods in your assertion class allows you to change the behaviour of the assertions:
|
||||
|
||||
* `public static function __callStatic($name, $arguments)`
|
||||
* This method is used to 'create' the `nullOr` and `all` versions of the assertions.
|
||||
* `protected static function valueToString($value)`
|
||||
* This method is used for error messages, to convert the value to a string value for displaying. You could use this for representing a value object with a `__toString` method for example.
|
||||
* `protected static function typeToString($value)`
|
||||
* This method is used for error messages, to convert the a value to a string representing its type.
|
||||
* `protected static function strlen($value)`
|
||||
* This method is used to calculate string lenght for relevant methods, using the `mb_strlen` if available and usefull.
|
||||
* `protected static function reportInvalidArgument($message)`
|
||||
* This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something.
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
|
|
@ -229,12 +259,6 @@ Contributions to the package are always welcome!
|
|||
* Report any bugs or issues you find on the [issue tracker].
|
||||
* You can grab the source code at the package's [Git repository].
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
If you are having problems, send a mail to bschussek@gmail.com or shout out to
|
||||
[@webmozart] on Twitter.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue