Added vendor/ directory for Composer's installed files
This commit is contained in:
parent
45df179c49
commit
b66a773ed8
262
vendor/alexgarrett/violin/README.md
vendored
Executable file
262
vendor/alexgarrett/violin/README.md
vendored
Executable file
@ -0,0 +1,262 @@
|
||||
# violin
|
||||
|
||||
[![Build Status](https://travis-ci.org/alexgarrett/violin.svg?branch=master)](https://travis-ci.org/alexgarrett/violin)
|
||||
|
||||
Violin is an easy to use, highly customisable PHP validator.
|
||||
|
||||
**Note: This package is under heavy development and is not recommended for production.**
|
||||
|
||||
## Installing
|
||||
|
||||
Install using Composer.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"alexgarrett/violin": "2.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Basic usage
|
||||
|
||||
```php
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'name' => ['billy', 'required'],
|
||||
'age' => [20, 'required|int']
|
||||
]);
|
||||
|
||||
if($v->passes()) {
|
||||
echo 'Validation passed, woo!';
|
||||
} else {
|
||||
echo '<pre>', var_dump($v->errors()->all()), '</pre>';
|
||||
}
|
||||
```
|
||||
|
||||
## Adding custom rules
|
||||
|
||||
Adding custom rules is simple. If the closure returns false, the rule fails.
|
||||
|
||||
```php
|
||||
$v->addRuleMessage('isbanana', 'The {field} field expects "banana", found "{value}" instead.');
|
||||
|
||||
$v->addRule('isbanana', function($value, $input, $args) {
|
||||
return $value === 'banana';
|
||||
});
|
||||
|
||||
$v->validate([
|
||||
'fruit' => ['apple', 'isbanana']
|
||||
]);
|
||||
```
|
||||
|
||||
## Adding custom error messages
|
||||
|
||||
You can add rule messages, or field messages for total flexibility.
|
||||
|
||||
### Adding a rule message
|
||||
|
||||
```php
|
||||
$v->addRuleMessage('required', 'You better fill in the {field} field, or else.');
|
||||
```
|
||||
|
||||
### Adding rule messages in bulk
|
||||
|
||||
```php
|
||||
$v->addRuleMessages([
|
||||
'required' => 'You better fill in the {field} field, or else.',
|
||||
'int' => 'The {field} needs to be an integer, but I found {value}.',
|
||||
]);
|
||||
```
|
||||
|
||||
### Adding a field message
|
||||
|
||||
Any field messages you add are used before any default or custom rule messages.
|
||||
|
||||
```php
|
||||
$v->addFieldMessage('username', 'required', 'You need to enter a username to sign up.');
|
||||
```
|
||||
|
||||
### Adding field messages in bulk
|
||||
|
||||
```php
|
||||
$v->addFieldMessages([
|
||||
'username' => [
|
||||
'required' => 'You need to enter a username to sign up.'
|
||||
],
|
||||
'age' => [
|
||||
'required' => 'I need your age.',
|
||||
'int' => 'Your age needs to be an integer.',
|
||||
]
|
||||
]);
|
||||
```
|
||||
|
||||
### Using Field Aliases
|
||||
|
||||
Field Aliases helps you format any error messages without showing weird form names or the need to create a custom error.
|
||||
|
||||
```php
|
||||
$v->validate([
|
||||
'username_box|Username' => ['' => 'required']
|
||||
]);
|
||||
|
||||
// Error output: "Username is required."
|
||||
```
|
||||
### Extending Violin
|
||||
|
||||
You can extend the Violin class to add custom rules, rule messages and field messages. This way, you can keep a tidy class to handle custom validation if you have any dependencies, like a database connection or language files.
|
||||
|
||||
```php
|
||||
class MyValidator extends Violin
|
||||
{
|
||||
protected $db;
|
||||
|
||||
public function __construct(PDO $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
// Add rule message for custom rule method.
|
||||
$this->addRuleMessage('uniqueUsername', 'That username is taken.');
|
||||
}
|
||||
|
||||
// Custom rule method for checking a unique username in our database.
|
||||
// Just prepend custom rules with validate_
|
||||
public function validate_uniqueUsername($value, $input, $args)
|
||||
{
|
||||
$user = $this->db->prepare("
|
||||
SELECT count(*) as count
|
||||
FROM users
|
||||
WHERE username = :username
|
||||
");
|
||||
|
||||
$user->execute(['username' => $value]);
|
||||
|
||||
if($user->fetchObject()->count) {
|
||||
return false; // Username exists, so return false.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// A database connection.
|
||||
$db = new PDO('mysql:host=127.0.0.1;dbname=website', 'root', 'root');
|
||||
|
||||
// Instantiate your custom class with dependencies.
|
||||
$v = new MyValidator($db);
|
||||
|
||||
$v->validate([
|
||||
'username' => ['billy', 'required|uniqueUsername']
|
||||
]);
|
||||
```
|
||||
|
||||
## Rules
|
||||
|
||||
This list of rules are **in progress**. Of course, you can always contribute to the project if you'd like to add more to the base ruleset.
|
||||
|
||||
#### alnum
|
||||
|
||||
If the value is alphanumeric.
|
||||
|
||||
#### alnumDash
|
||||
|
||||
If the value is alphanumeric. Dashes and underscores are permitted.
|
||||
|
||||
#### alpha
|
||||
|
||||
If the value is alphabetic letters only.
|
||||
|
||||
#### alphaDash
|
||||
|
||||
If the value is alphabetic letters only. Dashes and underscores are permitted.
|
||||
|
||||
#### array
|
||||
|
||||
If the value is an array.
|
||||
|
||||
#### between(int, int)
|
||||
|
||||
Checks if the value is within the intervals defined. This check is inclusive, so 5 is between 5 and 10.
|
||||
|
||||
#### bool
|
||||
|
||||
If the value is a boolean.
|
||||
|
||||
#### email
|
||||
|
||||
If the value is a valid email.
|
||||
|
||||
#### int
|
||||
|
||||
If the value is an integer, including numbers within strings. 1 and '1' are both classed as integers.
|
||||
|
||||
#### number
|
||||
|
||||
If the value is a number, including numbers within strings.
|
||||
|
||||
> Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal (e.g. 0xf4c3b00c), Binary (e.g. 0b10100111001), Octal (e.g. 0777) notation is allowed too but only without sign, decimal and exponential part.
|
||||
|
||||
#### ip
|
||||
|
||||
If the value is a valid IP address.
|
||||
|
||||
#### min(int, [number])
|
||||
|
||||
Check if string length is greater than or equal to given `int`. To check the size of a number, pass the optional `number` option.
|
||||
|
||||
```php
|
||||
$v->validate([
|
||||
'username' => ['billy', 'required|min(3)|max(20)'],
|
||||
'age' => ['20', 'required|min(18, number)|max(100, number)']
|
||||
]);
|
||||
```
|
||||
|
||||
#### max(int, [number])
|
||||
|
||||
Check if string length is less than or equal to given `int`. To check the size of a number, pass the optional `number` option.
|
||||
|
||||
#### required
|
||||
|
||||
If the value is present.
|
||||
|
||||
#### url
|
||||
|
||||
If the value is formatted as a valid URL.
|
||||
|
||||
#### matches(field)
|
||||
|
||||
Checks if one given input matches the other. For example, checking if *password* matches *password_confirm*.
|
||||
|
||||
#### date
|
||||
|
||||
If the given input is a valid date.
|
||||
|
||||
You can validate human readable dates like '25th October 1961' and instances of `DateTime`. For example:
|
||||
|
||||
```php
|
||||
$twoDaysAgo = new DateTime('2 days ago');
|
||||
$date = $twoDaysAgo->format('d M Y');
|
||||
|
||||
$v->validate([
|
||||
'date' => [$date, 'required|date']
|
||||
]);
|
||||
```
|
||||
|
||||
#### checked
|
||||
|
||||
If a field has been 'checked' or not, meaning it contains one of the following values: *'yes'*, *'on'*, *'1'*, *1*, *true*, or *'true'*. This can be used for determining if an HTML checkbox has been checked.
|
||||
|
||||
#### regex(expression)
|
||||
|
||||
If the given input has a match for the regular expression given.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please file issues under GitHub, or submit a pull request if you'd like to directly contribute.
|
||||
|
||||
### Running tests
|
||||
|
||||
Tests are run with phpunit. Run `./vendor/bin/phpunit` to run tests.
|
27
vendor/alexgarrett/violin/composer.json
vendored
Executable file
27
vendor/alexgarrett/violin/composer.json
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "alexgarrett/violin",
|
||||
"type": "library",
|
||||
"description": "Violin is an easy to use, highly customisable PHP validator.",
|
||||
"keywords": ["validation"],
|
||||
"homepage": "https://github.com/alexgarrett/violin",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex Garrett",
|
||||
"email": "alex@codecourse.com",
|
||||
"homepage": "http://itsmealex.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "2.1.*",
|
||||
"phpunit/phpunit": "~4.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Violin\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
77
vendor/alexgarrett/violin/examples/advanced/extending.php
vendored
Executable file
77
vendor/alexgarrett/violin/examples/advanced/extending.php
vendored
Executable file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Extending.
|
||||
*
|
||||
* You can extend the Violin class to create your own validator,
|
||||
* making it easier to keep everything in one place, and more
|
||||
* importantly, the ability to pass dependencies into the
|
||||
* class.
|
||||
*
|
||||
* This example checks a specfic value isn't already taken
|
||||
* within a table in your database.
|
||||
*/
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
//-- Validator.php
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
class Validator extends Violin
|
||||
{
|
||||
protected $db;
|
||||
|
||||
public function __construct(PDO $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
$this->addRuleMessage('unique', 'That {field} is already taken.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value already exists in a database table.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array $input
|
||||
* @param array $args
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate_unique($value, $input, $args)
|
||||
{
|
||||
$table = $args[0];
|
||||
$column = $args[1];
|
||||
$value = trim($value);
|
||||
|
||||
$exists = $this->db->prepare("
|
||||
SELECT count(*) as count
|
||||
FROM {$table}
|
||||
WHERE {$column} = :value
|
||||
");
|
||||
|
||||
$exists->execute([
|
||||
'value' => $value
|
||||
]);
|
||||
|
||||
return ! (bool) $exists->fetchObject()->count;
|
||||
}
|
||||
}
|
||||
|
||||
//-- Any other file
|
||||
|
||||
// Some database dependency
|
||||
$db = new PDO('mysql:dbname=project;host=localhost', 'root', 'root');
|
||||
|
||||
$v = new Validator($db);
|
||||
|
||||
$v->validate([
|
||||
'username' => ['alex', 'required|alpha|min(3)|max(20)|unique(users, username)'],
|
||||
'email' => ['alex@codecourse.com', 'required|email|unique(users, email)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
28
vendor/alexgarrett/violin/examples/basic.php
vendored
Executable file
28
vendor/alexgarrett/violin/examples/basic.php
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Basic validation.
|
||||
*
|
||||
* This shows basic validation, passing in an array to the
|
||||
* validate method and checking if the validation passes
|
||||
* with the passes method. Then dumps errors if failed.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dale', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale@codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_confirm' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
37
vendor/alexgarrett/violin/examples/basic_two_array.php
vendored
Executable file
37
vendor/alexgarrett/violin/examples/basic_two_array.php
vendored
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Basic validation, two arrays.
|
||||
*
|
||||
* This shows basic validation using two arrays, one for data,
|
||||
* and one for the ruleset. This is useful if you'd like to
|
||||
* extract the rules to a seperate class or variable.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$data = [
|
||||
'username' => 'dale',
|
||||
'email' => 'dale@codecourse.com',
|
||||
'password' => 'ilovecats',
|
||||
'password_confirm' => 'ilovecats'
|
||||
];
|
||||
|
||||
$rules = [
|
||||
'username' => 'required|alpha|min(3)|max(20)',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
'password_confirm' => 'required|matches(password)'
|
||||
];
|
||||
|
||||
$v->validate($data, $rules);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
21
vendor/alexgarrett/violin/examples/errors/errors_all.php
vendored
Executable file
21
vendor/alexgarrett/violin/examples/errors/errors_all.php
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. All errors.
|
||||
*
|
||||
* Simply getting a list of errors that occured while trying
|
||||
* to validate the data passed in against the rules given.
|
||||
*/
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dalegarrett1234567890', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale.codecourse.com', 'required|email']
|
||||
]);
|
||||
|
||||
var_dump($v->errors()->all()); // Array of all errors.
|
22
vendor/alexgarrett/violin/examples/errors/errors_field.php
vendored
Executable file
22
vendor/alexgarrett/violin/examples/errors/errors_field.php
vendored
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Errors for a specific field.
|
||||
*
|
||||
* Simply getting a list of errors for a specific field that
|
||||
* occured while trying to validate the data passed in
|
||||
* against the rules given.
|
||||
*/
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dalegarrett1234567890', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale.codecourse.com', 'required|email']
|
||||
]);
|
||||
|
||||
var_dump($v->errors()->get('username')); // Array of all 'username' errors.
|
25
vendor/alexgarrett/violin/examples/errors/errors_first.php
vendored
Executable file
25
vendor/alexgarrett/violin/examples/errors/errors_first.php
vendored
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Checking and getting first error.
|
||||
*
|
||||
* This checks a specific field has an error, and then outputs
|
||||
* the first error that occured for that field. This is most
|
||||
* likely what you'd use in a real life situation within
|
||||
* your HTML form.
|
||||
*/
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dalegarrett1234567890', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale.codecourse.com', 'required|email']
|
||||
]);
|
||||
|
||||
if ($v->errors()->has('email')) { // Check if any errors exist for 'email'.
|
||||
echo $v->errors()->first('email'); // First 'email' error (string).
|
||||
}
|
29
vendor/alexgarrett/violin/examples/messages/custom_field_message.php
vendored
Executable file
29
vendor/alexgarrett/violin/examples/messages/custom_field_message.php
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom field message.
|
||||
*
|
||||
* Defining an error message for a particular field, when a
|
||||
* particular rule fails.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addFieldMessage('username', 'required', 'We need a username to sign you up.');
|
||||
|
||||
$v->validate([
|
||||
'username' => ['', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale@codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_confirm' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
40
vendor/alexgarrett/violin/examples/messages/custom_field_messages.php
vendored
Executable file
40
vendor/alexgarrett/violin/examples/messages/custom_field_messages.php
vendored
Executable file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom field messages.
|
||||
*
|
||||
* Defining an error message for a particular field, when a
|
||||
* particular rule fails.
|
||||
*
|
||||
* This is the same as addFieldMessage, but allows adding
|
||||
* of multiple field messages in one go.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addFieldMessages([
|
||||
'username' => [
|
||||
'required' => 'We need a username to sign you up.',
|
||||
'alpha' => 'Your username can only contain letters.'
|
||||
],
|
||||
'email' => [
|
||||
'email' => 'That email doesn\'t look valid.'
|
||||
]
|
||||
]);
|
||||
|
||||
$v->validate([
|
||||
'username' => ['cats4life', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale.codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_confirm' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
28
vendor/alexgarrett/violin/examples/messages/custom_rule_message.php
vendored
Executable file
28
vendor/alexgarrett/violin/examples/messages/custom_rule_message.php
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom rule message.
|
||||
*
|
||||
* Defining an error message for when a particular rule fails.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('required', 'Hold up, the {field} field is required!');
|
||||
|
||||
$v->validate([
|
||||
'username' => ['', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale@codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_confirm' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
34
vendor/alexgarrett/violin/examples/messages/custom_rule_messages.php
vendored
Executable file
34
vendor/alexgarrett/violin/examples/messages/custom_rule_messages.php
vendored
Executable file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom rule message.
|
||||
*
|
||||
* Defining an error message for when a particular rule fails.
|
||||
*
|
||||
* This is the same as addRuleMessage, but allows adding
|
||||
* of multiple rule messages in one go.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessages([
|
||||
'required' => 'Hold up, the {field} field is required!',
|
||||
'email' => 'That doesn\'t look like a valid email address to me.'
|
||||
]);
|
||||
|
||||
$v->validate([
|
||||
'username' => ['', 'required|alpha|min(3)|max(20)'],
|
||||
'email' => ['dale.codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_confirm' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
26
vendor/alexgarrett/violin/examples/messages/field_aliases.php
vendored
Executable file
26
vendor/alexgarrett/violin/examples/messages/field_aliases.php
vendored
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Field aliases.
|
||||
*
|
||||
* Shows using field aliases to rename fields without having
|
||||
* to define custom rule or field messages, making it a
|
||||
* cleaner solution if this will suffice.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->validate([
|
||||
'username|Username' => ['', 'required'],
|
||||
'password|Password' => ['', 'required']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
27
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders.php
vendored
Executable file
27
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders.php
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Message placeholders.
|
||||
*
|
||||
* Shows the placeholders you can use when defining messages. You can
|
||||
* output the name of the field, the value given by the user, and
|
||||
* the arguments that were passed into the rule.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('between', 'The {field} must be between {$0} and {$1}, you gave {value}');
|
||||
|
||||
$v->validate([
|
||||
'age' => ['82', 'required|between(18, 35)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
31
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders_all.php
vendored
Executable file
31
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders_all.php
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Message placeholders.
|
||||
*
|
||||
* Shows how you can output all arguments as a comma seperated list,
|
||||
* if you have a variable amount of arguments for a rule.
|
||||
*/
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('isoneof', '{field} must be one of {$*}');
|
||||
|
||||
$v->addRule('isoneof', function($value, $input, $args) {
|
||||
$value = trim($value);
|
||||
return in_array($value, $args);
|
||||
});
|
||||
|
||||
$v->validate([
|
||||
'age' => ['sheep', 'required|isoneof(apples, pears)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
32
vendor/alexgarrett/violin/examples/rules/custom_rule.php
vendored
Executable file
32
vendor/alexgarrett/violin/examples/rules/custom_rule.php
vendored
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom rule.
|
||||
*
|
||||
* Creating a custom rule using the addRule method, passing in a
|
||||
* closure which should return false if the check has failed,
|
||||
* or true if the check has passed.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('startsWithNumber', 'The {field} must start with a number.');
|
||||
|
||||
$v->addRule('startsWithNumber', function($value, $input, $args) {
|
||||
$value = trim($value);
|
||||
return is_numeric($value[0]);
|
||||
});
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dale', 'required|min(3)|max(20)|startsWithNumber']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
35
vendor/alexgarrett/violin/examples/rules/custom_rule_arguments.php
vendored
Executable file
35
vendor/alexgarrett/violin/examples/rules/custom_rule_arguments.php
vendored
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Custom rule.
|
||||
*
|
||||
* Creating a custom rule using the addRule method, passing in a
|
||||
* closure which should return false if the check has failed,
|
||||
* or true if the check has passed.
|
||||
*
|
||||
* This example shows the use of arguments that can be used
|
||||
* to make rules that require arguments.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('startsWith', 'The {field} must start with "{$0}".');
|
||||
|
||||
$v->addRule('startsWith', function($value, $input, $args) {
|
||||
$value = trim($value);
|
||||
return $value[0] === $args[0];
|
||||
});
|
||||
|
||||
$v->validate([
|
||||
'username' => ['dale', 'required|min(3)|max(20)|startsWith(a)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
18
vendor/alexgarrett/violin/phpunit.xml
vendored
Executable file
18
vendor/alexgarrett/violin/phpunit.xml
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Violin Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
12
vendor/alexgarrett/violin/src/Contracts/MessageBagContract.php
vendored
Executable file
12
vendor/alexgarrett/violin/src/Contracts/MessageBagContract.php
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Contracts;
|
||||
|
||||
interface MessageBagContract
|
||||
{
|
||||
public function has($key);
|
||||
public function first($key);
|
||||
public function get($key);
|
||||
public function all();
|
||||
public function keys();
|
||||
}
|
33
vendor/alexgarrett/violin/src/Contracts/RuleContract.php
vendored
Executable file
33
vendor/alexgarrett/violin/src/Contracts/RuleContract.php
vendored
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Contracts;
|
||||
|
||||
interface RuleContract
|
||||
{
|
||||
/**
|
||||
* Runs the rule to check validity. Returning false fails
|
||||
* the check and returning true passes the check.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array $input
|
||||
* @param array $args
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function run($value, $input, $args);
|
||||
|
||||
/**
|
||||
* The error given if the rule fails.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error();
|
||||
|
||||
/**
|
||||
* If the rule can be skipped, if the value given
|
||||
* to the validator is not required.
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function canSkip();
|
||||
}
|
18
vendor/alexgarrett/violin/src/Contracts/ValidatorContract.php
vendored
Executable file
18
vendor/alexgarrett/violin/src/Contracts/ValidatorContract.php
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Contracts;
|
||||
|
||||
use Closure;
|
||||
|
||||
interface ValidatorContract
|
||||
{
|
||||
public function validate(array $input, $rules = []);
|
||||
public function passes();
|
||||
public function fails();
|
||||
public function errors();
|
||||
public function addRuleMessage($rule, $message);
|
||||
public function addRuleMessages(array $messages);
|
||||
public function addFieldMessage($field, $rule, $message);
|
||||
public function addFieldMessages(array $messages);
|
||||
public function addRule($name, Closure $callback);
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/AlnumDashRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/AlnumDashRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class AlnumDashRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return (bool) preg_match('/^[\pL\pM\pN_-]+$/u', $value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be alphanumeric with dashes and underscores permitted.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/AlnumRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/AlnumRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class AlnumRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return (bool) preg_match('/^[\pL\pM\pN]+$/u', $value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be alphanumeric.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/AlphaRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/AlphaRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class AlphaRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return (bool) preg_match('/^[\pL\pM]+$/u', $value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be alphabetic.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/ArrayRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/ArrayRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class ArrayRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return is_array($value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be an array.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/BetweenRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/BetweenRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class BetweenRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return ($value >= $args[0] && $value <= $args[1]) ? true : false;
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be between {$0} and {$1}.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/BoolRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/BoolRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class BoolRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return is_bool($value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a boolean.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/CheckedRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/CheckedRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class CheckedRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return in_array($value, ['yes', 'on', '1', 1, true, 'true'], true);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return 'You need to check the {field} field.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
33
vendor/alexgarrett/violin/src/Rules/DateRule.php
vendored
Executable file
33
vendor/alexgarrett/violin/src/Rules/DateRule.php
vendored
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class DateRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strtotime($value) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$date = date_parse($value);
|
||||
|
||||
return checkdate($date['month'], $date['day'], $date['year']);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a valid date.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/EmailRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/EmailRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class EmailRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a valid email address.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/IntRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/IntRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class IntRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return is_numeric($value) && (int)$value == $value;
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a number.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/IpRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/IpRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class IpRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_IP) !== false;
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a valid IP address.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/MatchesRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/MatchesRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class MatchesRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return $value === $input[$args[0]];
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must match {$0}.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
29
vendor/alexgarrett/violin/src/Rules/MaxRule.php
vendored
Executable file
29
vendor/alexgarrett/violin/src/Rules/MaxRule.php
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class MaxRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
$number = isset($args[1]) && $args[1] === 'number';
|
||||
|
||||
if ($number) {
|
||||
return (float) $value <= (float) $args[0];
|
||||
}
|
||||
|
||||
return mb_strlen($value) <= (int) $args[0];
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a maximum of {$0}.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
29
vendor/alexgarrett/violin/src/Rules/MinRule.php
vendored
Executable file
29
vendor/alexgarrett/violin/src/Rules/MinRule.php
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class MinRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
$number = isset($args[1]) && $args[1] === 'number';
|
||||
|
||||
if ($number) {
|
||||
return (float) $value >= (float) $args[0];
|
||||
}
|
||||
|
||||
return mb_strlen($value) >= (int) $args[0];
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a minimum of {$0}.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/NumberRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/NumberRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class NumberRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return is_numeric($value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a number.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/RegexRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/RegexRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class RegexRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return (bool) preg_match($args[0], $value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} was not in the correct format.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
25
vendor/alexgarrett/violin/src/Rules/RequiredRule.php
vendored
Executable file
25
vendor/alexgarrett/violin/src/Rules/RequiredRule.php
vendored
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class RequiredRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
$value = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $value);
|
||||
|
||||
return !empty($value);
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} is required.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
23
vendor/alexgarrett/violin/src/Rules/UrlRule.php
vendored
Executable file
23
vendor/alexgarrett/violin/src/Rules/UrlRule.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Rules;
|
||||
|
||||
use Violin\Contracts\RuleContract;
|
||||
|
||||
class UrlRule implements RuleContract
|
||||
{
|
||||
public function run($value, $input, $args)
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
|
||||
public function error()
|
||||
{
|
||||
return '{field} must be a valid URL.';
|
||||
}
|
||||
|
||||
public function canSkip()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
96
vendor/alexgarrett/violin/src/Support/MessageBag.php
vendored
Executable file
96
vendor/alexgarrett/violin/src/Support/MessageBag.php
vendored
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Violin\Support;
|
||||
|
||||
use RecursiveArrayIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
use Violin\Contracts\MessageBagContract;
|
||||
|
||||
class MessageBag implements MessageBagContract
|
||||
{
|
||||
/**
|
||||
* The registered messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $messages = [];
|
||||
|
||||
/**
|
||||
* Creates a new instange of the MessageBag instance.
|
||||
*
|
||||
* @param array $messages
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $messages)
|
||||
{
|
||||
foreach ($messages as $key => $value) {
|
||||
$this->messages[$key] = (array) $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bag has messages for a given key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return ! is_null($this->first($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first message with a given key.
|
||||
* If the given key doesn't exist, it returns the first
|
||||
* message of the bag.
|
||||
* Returns null if the bag is empty.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function first($key = null)
|
||||
{
|
||||
$messages = is_null($key) ? $this->all() : $this->get($key);
|
||||
return (count($messages) > 0) ? $messages[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the messages from a given key.
|
||||
* Returns null if the given key is empty, or
|
||||
* if it doesn't exist.
|
||||
*
|
||||
* @param string $key
|
||||
* @return array|null
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->messages)) {
|
||||
return !empty($this->messages[$key]) ? $this->messages[$key] : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the messages in the bag.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return iterator_to_array(new RecursiveIteratorIterator(
|
||||
new RecursiveArrayIterator($this->messages)
|
||||
), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the keys in the bag.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->messages);
|
||||
}
|
||||
}
|
506
vendor/alexgarrett/violin/src/Violin.php
vendored
Executable file
506
vendor/alexgarrett/violin/src/Violin.php
vendored
Executable file
@ -0,0 +1,506 @@
|
||||
<?php
|
||||
|
||||
namespace Violin;
|
||||
|
||||
use Closure;
|
||||
|
||||
use RecursiveArrayIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
use Violin\Support\MessageBag;
|
||||
use Violin\Contracts\ValidatorContract;
|
||||
|
||||
class Violin implements ValidatorContract
|
||||
{
|
||||
/**
|
||||
* Rule objects that have already been instantiated.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $usedRules = [];
|
||||
|
||||
/**
|
||||
* Custom user-defined rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customRules = [];
|
||||
|
||||
/**
|
||||
* Collection of errors.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $errors = [];
|
||||
|
||||
/**
|
||||
* Inputted fields and values.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $input = [];
|
||||
|
||||
/**
|
||||
* Rule messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $ruleMessages = [];
|
||||
|
||||
/**
|
||||
* Field messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldMessages = [];
|
||||
|
||||
/**
|
||||
* Field Aliases.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldAliases = [];
|
||||
|
||||
/**
|
||||
* Kick off the validation using input and rules.
|
||||
*
|
||||
* @param array $input
|
||||
* @param array $rules
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public function validate(array $data, $rules = [])
|
||||
{
|
||||
$this->clearErrors();
|
||||
$this->clearFieldAliases();
|
||||
|
||||
$data = $this->extractFieldAliases($data);
|
||||
|
||||
// If the rules array is empty, then it means we are
|
||||
// receiving the rules directly with the input, so we need
|
||||
// to extract the information.
|
||||
if (empty($rules)) {
|
||||
$rules = $this->extractRules($data);
|
||||
$data = $this->extractInput($data);
|
||||
}
|
||||
|
||||
$this->input = $data;
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
$fieldRules = explode('|', $rules[$field]);
|
||||
|
||||
foreach ($fieldRules as $rule) {
|
||||
$this->validateAgainstRule(
|
||||
$field,
|
||||
$value,
|
||||
$this->getRuleName($rule),
|
||||
$this->getRuleArgs($rule)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if validation has passed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function passes()
|
||||
{
|
||||
return empty($this->errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if validation has failed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function fails()
|
||||
{
|
||||
return ! $this->passes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gather errors, format them and return them.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function errors()
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
foreach ($this->errors as $rule => $items) {
|
||||
foreach ($items as $item) {
|
||||
$field = $item['field'];
|
||||
|
||||
$message = $this->fetchMessage($field, $rule);
|
||||
|
||||
// If there is any alias for the current field, swap it.
|
||||
if (isset($this->fieldAliases[$field])) {
|
||||
$item['field'] = $this->fieldAliases[$field];
|
||||
}
|
||||
|
||||
$messages[$field][] = $this->replaceMessageFormat($message, $item);
|
||||
}
|
||||
}
|
||||
|
||||
return new MessageBag($messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom rule message.
|
||||
*
|
||||
* @param string $rule
|
||||
* @param string $message
|
||||
*/
|
||||
public function addRuleMessage($rule, $message)
|
||||
{
|
||||
$this->ruleMessages[$rule] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom rule messages.
|
||||
*
|
||||
* @param array $messages
|
||||
*/
|
||||
public function addRuleMessages(array $messages)
|
||||
{
|
||||
$this->ruleMessages = array_merge($this->ruleMessages, $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom field message.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $rule
|
||||
* @param string $message
|
||||
*/
|
||||
public function addFieldMessage($field, $rule, $message)
|
||||
{
|
||||
$this->fieldMessages[$field][$rule] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom field messages
|
||||
*
|
||||
* @param array $messages
|
||||
*/
|
||||
public function addFieldMessages(array $messages)
|
||||
{
|
||||
$this->fieldMessages = $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a custom rule
|
||||
*
|
||||
* @param string $name
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function addRule($name, Closure $callback)
|
||||
{
|
||||
$this->customRules[$name] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the message for an error by field or rule type.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $rule
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function fetchMessage($field, $rule)
|
||||
{
|
||||
if (isset($this->fieldMessages[$field][$rule])) {
|
||||
return $this->fieldMessages[$field][$rule];
|
||||
}
|
||||
|
||||
if (isset($this->ruleMessages[$rule])) {
|
||||
return $this->ruleMessages[$rule];
|
||||
}
|
||||
|
||||
return $this->usedRules[$rule]->error();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces message variables.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replaceMessageFormat($message, array $item)
|
||||
{
|
||||
$keys = array_keys($item);
|
||||
|
||||
if (!empty($item['args'])) {
|
||||
$args = $item['args'];
|
||||
|
||||
$argReplace = array_map(function($i) {
|
||||
return "{\${$i}}";
|
||||
}, array_keys($args));
|
||||
|
||||
// Number of arguments
|
||||
$args[] = count($item['args']);
|
||||
$argReplace[] = '{$#}';
|
||||
|
||||
// All arguments
|
||||
$args[] = implode(', ', $item['args']);
|
||||
$argReplace[] = '{$*}';
|
||||
|
||||
// Replace arguments
|
||||
$message = str_replace($argReplace, $args, $message);
|
||||
}
|
||||
|
||||
// Replace field and value
|
||||
$message = str_replace(
|
||||
['{field}', '{value}'],
|
||||
[$item['field'], $item['value']],
|
||||
$message
|
||||
);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates value against a specific rule and handles
|
||||
* errors if the rule validation fails.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
* @param string $rule
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function validateAgainstRule($field, $value, $rule, array $args)
|
||||
{
|
||||
$ruleToCall = $this->getRuleToCall($rule);
|
||||
|
||||
if ($this->canSkipRule($ruleToCall, $value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$passed = call_user_func_array($ruleToCall, [
|
||||
$value,
|
||||
$this->input,
|
||||
$args
|
||||
]);
|
||||
|
||||
if (!$passed) {
|
||||
$this->handleError($field, $value, $rule, $args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to help skip a rule if a value is empty, since we
|
||||
* don't need to validate an empty value. If the rule to
|
||||
* call specifically doesn't allowing skipping, then
|
||||
* we don't want skip the rule.
|
||||
*
|
||||
* @param array $ruleToCall
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function canSkipRule($ruleToCall, $value)
|
||||
{
|
||||
return (
|
||||
(is_array($ruleToCall) &&
|
||||
method_exists($ruleToCall[0], 'canSkip') &&
|
||||
$ruleToCall[0]->canSkip()) &&
|
||||
empty($value) &&
|
||||
!is_array($value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all previously stored errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearErrors()
|
||||
{
|
||||
$this->errors = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an error.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $value
|
||||
* @param string $rule
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleError($field, $value, $rule, array $args)
|
||||
{
|
||||
$this->errors[$rule][] = [
|
||||
'field' => $field,
|
||||
'value' => $value,
|
||||
'args' => $args,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets and instantiates a rule object, e.g. IntRule. If it has
|
||||
* already been used, it pulls from the stored rule objects.
|
||||
*
|
||||
* @param string $rule
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getRuleToCall($rule)
|
||||
{
|
||||
if (isset($this->customRules[$rule])) {
|
||||
return $this->customRules[$rule];
|
||||
}
|
||||
|
||||
if (method_exists($this, 'validate_' . $rule)) {
|
||||
return [$this, 'validate_' . $rule];
|
||||
}
|
||||
|
||||
if (isset($this->usedRules[$rule])) {
|
||||
return [$this->usedRules[$rule], 'run'];
|
||||
}
|
||||
|
||||
$ruleClass = 'Violin\\Rules\\' . ucfirst($rule) . 'Rule';
|
||||
$ruleObject = new $ruleClass();
|
||||
|
||||
$this->usedRules[$rule] = $ruleObject;
|
||||
|
||||
return [$ruleObject, 'run'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a rule has arguments.
|
||||
*
|
||||
* @param string $rule
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function ruleHasArgs($rule)
|
||||
{
|
||||
return isset(explode('(', $rule)[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rule arguments.
|
||||
*
|
||||
* @param string $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRuleArgs($rule)
|
||||
{
|
||||
if (!$this->ruleHasArgs($rule)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
list($ruleName, $argsWithBracketAtTheEnd) = explode('(', $rule);
|
||||
|
||||
$args = rtrim($argsWithBracketAtTheEnd, ')');
|
||||
$args = preg_replace('/\s+/', '', $args);
|
||||
$args = explode(',', $args);
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a rule name.
|
||||
*
|
||||
* @param string $rule
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRuleName($rule)
|
||||
{
|
||||
return explode('(', $rule)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten an array.
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function flattenArray(array $args)
|
||||
{
|
||||
return iterator_to_array(new RecursiveIteratorIterator(
|
||||
new RecursiveArrayIterator($args)
|
||||
), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts field aliases from an input.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function extractFieldAliases(array $data)
|
||||
{
|
||||
foreach ($data as $field => $fieldRules) {
|
||||
$extraction = explode('|', $field);
|
||||
|
||||
if (isset($extraction[1])) {
|
||||
$updatedField = $extraction[0];
|
||||
$alias = $extraction[1];
|
||||
|
||||
$this->fieldAliases[$updatedField] = $alias;
|
||||
$data[$updatedField] = $data[$field];
|
||||
unset($data[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all field aliases.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearFieldAliases()
|
||||
{
|
||||
$this->fieldAliases = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the field input from the data array.
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function extractInput(array $data)
|
||||
{
|
||||
$input = [];
|
||||
|
||||
foreach ($data as $field => $fieldData) {
|
||||
$input[$field] = $fieldData[0];
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the field ruleset from the data array.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function extractRules(array $data)
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
foreach ($data as $field => $fieldData) {
|
||||
$rules[$field] = $fieldData[1];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
68
vendor/alexgarrett/violin/tests/MessageBagTest.php
vendored
Executable file
68
vendor/alexgarrett/violin/tests/MessageBagTest.php
vendored
Executable file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use Violin\Support\MessageBag;
|
||||
|
||||
class MessageBagTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $mb;
|
||||
|
||||
protected $messages = [
|
||||
'name' => [
|
||||
'You must fill in the name field.',
|
||||
'Your name must only be letters.',
|
||||
],
|
||||
'username' => [
|
||||
'Your username is required.',
|
||||
'Your username must be alphanumeric (with dashes and underscores permitted)'
|
||||
],
|
||||
'password' => [
|
||||
'Your password must be greater than 6 characters.'
|
||||
]
|
||||
];
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mb = new MessageBag($this->messages);
|
||||
}
|
||||
|
||||
public function testMessageBagContainsCorrectKeys()
|
||||
{
|
||||
$keys = $this->mb->keys();
|
||||
|
||||
$this->assertContains('name', $keys);
|
||||
$this->assertContains('username', $keys);
|
||||
$this->assertContains('password', $keys);
|
||||
}
|
||||
|
||||
public function testFirstErrorForFieldExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
$this->mb->first('name'),
|
||||
$this->messages['name'][0]
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllErrorsForFieldExist()
|
||||
{
|
||||
$this->assertEquals(
|
||||
$this->mb->get('name'),
|
||||
$this->messages['name']
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllErrorsExist()
|
||||
{
|
||||
$flatMessages = iterator_to_array(new RecursiveIteratorIterator(
|
||||
new RecursiveArrayIterator($this->messages)
|
||||
), false);
|
||||
|
||||
$this->assertEquals($flatMessages, $this->mb->all());
|
||||
}
|
||||
|
||||
public function testMessageBagHasError()
|
||||
{
|
||||
$this->assertTrue($this->mb->has('name'));
|
||||
$this->assertTrue($this->mb->has('username'));
|
||||
$this->assertTrue($this->mb->has('password'));
|
||||
}
|
||||
}
|
567
vendor/alexgarrett/violin/tests/RulesTest.php
vendored
Executable file
567
vendor/alexgarrett/violin/tests/RulesTest.php
vendored
Executable file
@ -0,0 +1,567 @@
|
||||
<?php
|
||||
|
||||
use Violin\Rules\IpRule;
|
||||
use Violin\Rules\IntRule;
|
||||
use Violin\Rules\UrlRule;
|
||||
use Violin\Rules\MaxRule;
|
||||
use Violin\Rules\MinRule;
|
||||
use Violin\Rules\BoolRule;
|
||||
use Violin\Rules\DateRule;
|
||||
use Violin\Rules\RegexRule;
|
||||
use Violin\Rules\AlnumRule;
|
||||
use Violin\Rules\AlphaRule;
|
||||
use Violin\Rules\EmailRule;
|
||||
use Violin\Rules\ArrayRule;
|
||||
use Violin\Rules\NumberRule;
|
||||
use Violin\Rules\CheckedRule;
|
||||
use Violin\Rules\BetweenRule;
|
||||
use Violin\Rules\MatchesRule;
|
||||
use Violin\Rules\RequiredRule;
|
||||
use Violin\Rules\AlnumDashRule;
|
||||
|
||||
use Violin\Support\MessageBag;
|
||||
|
||||
class RulesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testBetweenRule()
|
||||
{
|
||||
$betweenRule = new BetweenRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$betweenRule->run('5', [], [10, 15])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$betweenRule->run(5, [], [10, 15])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$betweenRule->run('100', [], [100, 500])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$betweenRule->run(499, [], [100, 500])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$betweenRule->run('300', [], [100, 500])
|
||||
);
|
||||
}
|
||||
|
||||
public function testIntRule()
|
||||
{
|
||||
$intRule = new IntRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$intRule->run('two', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$intRule->run('2', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$intRule->run(10, [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testNumberRule()
|
||||
{
|
||||
$numberRule = new NumberRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$numberRule->run('dale', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$numberRule->run('', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$numberRule->run('three', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$numberRule->run('1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$numberRule->run('3.14159265359', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$numberRule->run(3.14159265359, [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testMatchesRule()
|
||||
{
|
||||
$matchesRule = new MatchesRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$matchesRule->run('cats', [
|
||||
'password' => 'cats',
|
||||
'password_again' => 'catz',
|
||||
], ['password_again'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$matchesRule->run('cats', [
|
||||
'password' => 'cats',
|
||||
'password_again' => 'cats',
|
||||
], ['password_again'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testRequiredRule()
|
||||
{
|
||||
$requiredRule = new RequiredRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$requiredRule->run('', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$requiredRule->run(' ', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$requiredRule->run(' ', [], [])
|
||||
); // Contains whitespace character
|
||||
|
||||
$this->assertTrue(
|
||||
$requiredRule->run('cats', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$requiredRule->run(' cats ', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testAlnumRule()
|
||||
{
|
||||
$alnumRule = new AlnumRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$alnumRule->run('cats_123', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$alnumRule->run('cats-_123', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$alnumRule->run('cats123!', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumRule->run('cats123', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumRule->run('cats', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testAlnumDashRule()
|
||||
{
|
||||
$alnumDashRule = new AlnumDashRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$alnumDashRule->run('cats123!', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$alnumDashRule->run('cats(123)', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumDashRule->run('cats_123', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumDashRule->run('i_love-cats', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumDashRule->run('cat__love', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alnumDashRule->run('cat--love', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testAlphaRule()
|
||||
{
|
||||
$alphaRule = new AlphaRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$alphaRule->run('cats123', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$alphaRule->run('cats!', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$alphaRule->run(' cats ', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$alphaRule->run('cats', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testArrayRule()
|
||||
{
|
||||
$arrayRule = new ArrayRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$arrayRule->run('not an array', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$arrayRule->run("['not', 'an', 'array']", [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$arrayRule->run(['an', 'array'], [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$arrayRule->run([], [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testBoolRule()
|
||||
{
|
||||
$boolRule = new BoolRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$boolRule->run('false', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$boolRule->run('true', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$boolRule->run(1, [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$boolRule->run(0, [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$boolRule->run(true, [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$boolRule->run(false, [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testEmailRule()
|
||||
{
|
||||
$emailRule = new EmailRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$emailRule->run('ilove@', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$emailRule->run('ilove@cats', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$emailRule->run('ilove@cats.com', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testIpRule()
|
||||
{
|
||||
$ipRule = new IpRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$ipRule->run('127', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$ipRule->run('127.0.0', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$ipRule->run('www.duckduckgo.com', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ipRule->run('0.0.0.0', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ipRule->run('127.0.0.1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ipRule->run('FE80:0000:0000:0000:0202:B3FF:FE1E:8329', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ipRule->run('FE80::0202:B3FF:FE1E:8329', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$ipRule->run('::1', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testMaxRuleWithNumbers()
|
||||
{
|
||||
$maxRule = new MaxRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$maxRule->run('100', [], ['10', 'number'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$maxRule->run(100, [], ['99', 'number'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$maxRule->run(3.14, [], ['3.10', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run('50', [], ['100', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run(50, [], ['100', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run('5.5', [], ['100', 'number'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testMinRuleWithNumbers()
|
||||
{
|
||||
$minRule = new MinRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run('10', [], ['100', 'number'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run(99, [], ['100', 'number'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run(3.10, [], ['3.14', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$minRule->run('100', [], ['50', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$minRule->run(100, [], ['50', 'number'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$minRule->run('100', [], ['5.5', 'number'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testMaxRuleWithStrings()
|
||||
{
|
||||
$maxRule = new MaxRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$maxRule->run('william', [], ['5'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$maxRule->run('100000', [], ['5'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run('billy', [], ['5'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run('100', [], ['5'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$maxRule->run('99999', [], ['5'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testMinRuleWithStrings()
|
||||
{
|
||||
$minRule = new MinRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run('billy', [], ['10'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run('5', [], ['10'])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$minRule->run('10', [], ['10'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$minRule->run('william', [], ['5'])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$minRule->run('99999', [], ['5'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testUrlRule()
|
||||
{
|
||||
$urlRule = new UrlRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$urlRule->run('www.com', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$urlRule->run('duckduckgo.com', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$urlRule->run('www.duckduckgo', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$urlRule->run('127.0.0.1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('http://www.duckduckgo.com', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('http://127.0.0.1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('ftp://127.0.0.1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('ssl://codecourse.com', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('ssl://127.0.0.1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$urlRule->run('http://codecourse.com', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateRule()
|
||||
{
|
||||
$dateRule = new DateRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$dateRule->run('', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$dateRule->run('0000-00-00', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$dateRule->run('40th November 1989', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$dateRule->run('16th November 1989', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$dateRule->run('1989-11-16', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$dateRule->run('16-11-1989', [], [])
|
||||
);
|
||||
|
||||
$dateTime = new DateTime('2 days ago');
|
||||
|
||||
$this->assertFalse(
|
||||
$dateRule->run($dateTime->format('x y z'), [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$dateRule->run($dateTime->format('d M Y'), [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testCheckedRule()
|
||||
{
|
||||
$checkedRule = new CheckedRule;
|
||||
|
||||
$this->assertFalse(
|
||||
$checkedRule->run('', [], [])
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$checkedRule->run(' ', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run('on', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run('yes', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run(1, [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run('1', [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run(true, [], [])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$checkedRule->run('true', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
public function testRegexRule()
|
||||
{
|
||||
$regexRule = new RegexRule;
|
||||
|
||||
$exampleRegex = '/b[aeiou]g/';
|
||||
|
||||
$this->assertFalse(
|
||||
$regexRule->run('banter', [], [$exampleRegex])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$regexRule->run('bag', [], [$exampleRegex])
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$regexRule->run('big', [], [$exampleRegex])
|
||||
);
|
||||
}
|
||||
}
|
272
vendor/alexgarrett/violin/tests/ValidatorTest.php
vendored
Executable file
272
vendor/alexgarrett/violin/tests/ValidatorTest.php
vendored
Executable file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
class ValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $v;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->v = new Violin;
|
||||
}
|
||||
|
||||
public function testBasicValidValidation()
|
||||
{
|
||||
$this->v->validate([
|
||||
'first_name' => ['Billy', 'required|alpha|max(20)'],
|
||||
'last_name' => ['Garrett', 'required|alpha|max(20)'],
|
||||
'email|Email' => ['billy@codecourse.com', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_again' => ['ilovecats', 'required|matches(password)']
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->v->passes());
|
||||
$this->assertFalse($this->v->fails());
|
||||
|
||||
$input = [
|
||||
'first_name' => 'Billy',
|
||||
'last_name' => 'Garrett',
|
||||
'email|Email' => 'billy@codecourse.com',
|
||||
'password' => 'ilovecats',
|
||||
'password' => 'ilovecats'
|
||||
];
|
||||
|
||||
$rules = [
|
||||
'first_name' => 'required|alpha|max(20)',
|
||||
'last_name' => 'required|alpha|max(20)',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
'password_again' => 'required|matches(password)'
|
||||
];
|
||||
|
||||
$this->v->validate($input, $rules);
|
||||
|
||||
$this->assertTrue($this->v->passes());
|
||||
$this->assertFalse($this->v->fails());
|
||||
}
|
||||
|
||||
public function testBasicInvalidValidation()
|
||||
{
|
||||
$this->v->validate([
|
||||
'first_name' => ['Billy', 'required|alpha|max(20)'],
|
||||
'last_name' => ['', 'required|alpha|max(20)'],
|
||||
'email' => ['billy@codecourse', 'required|email'],
|
||||
'password' => ['ilovecats', 'required'],
|
||||
'password_again' => ['ilovecatsanddogs' , 'required|matches(password)']
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->v->fails());
|
||||
$this->assertFalse($this->v->passes());
|
||||
}
|
||||
|
||||
public function testRuleMessage()
|
||||
{
|
||||
$this->v->addRuleMessage('required', 'This field is required!');
|
||||
|
||||
$this->v->validate([
|
||||
'username' => ['', 'required']
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->v->errors()->first('username'),
|
||||
'This field is required!'
|
||||
);
|
||||
}
|
||||
|
||||
public function testReplaceMessageFormatOnError()
|
||||
{
|
||||
$this->v->addRule('testRule', function($value, $input, $args) {
|
||||
return false;
|
||||
});
|
||||
|
||||
$this->v->addRuleMessage('testRule', 'We got {$#} arguments: {$*}.');
|
||||
|
||||
$this->v->validate([
|
||||
'age' => [0, 'testRule(1, 2, 3)']
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->v->errors()->first(),
|
||||
'We got 3 arguments: 1, 2, 3.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testRuleMessages()
|
||||
{
|
||||
$this->v->addRuleMessages([
|
||||
'required' => 'This field is required!',
|
||||
'alpha' => 'Only alpha characters please!',
|
||||
'email' => 'Enter a valid email!'
|
||||
]);
|
||||
|
||||
$this->v->validate([
|
||||
'username' => ['', 'required|alpha'],
|
||||
'name' => ['123', 'alpha'],
|
||||
'email' => ['notanemail', 'required|email']
|
||||
]);
|
||||
|
||||
$errors = $this->v->errors();
|
||||
|
||||
$this->assertEquals(
|
||||
$errors->get('username'),
|
||||
['This field is required!']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$errors->first('name'),
|
||||
'Only alpha characters please!'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$errors->first('email'),
|
||||
'Enter a valid email!'
|
||||
);
|
||||
}
|
||||
|
||||
public function testFieldMessage()
|
||||
{
|
||||
$this->v->addFieldMessage('username', 'required', 'We need a username, please.');
|
||||
|
||||
$this->v->validate([
|
||||
'username' => ['', 'required']
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->v->errors()->first('username'),
|
||||
'We need a username, please.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testFieldMessages()
|
||||
{
|
||||
$this->v->addFieldMessages([
|
||||
'username' => [
|
||||
'required' => 'We need a username, please.'
|
||||
],
|
||||
'email' => [
|
||||
'required' => 'How do you expect us to contact you without an email?'
|
||||
]
|
||||
]);
|
||||
|
||||
$this->v->validate([
|
||||
'username' => ['', 'required|alpha'],
|
||||
'email' => ['', 'required|email']
|
||||
]);
|
||||
|
||||
$errors = $this->v->errors();
|
||||
|
||||
$this->assertEquals(
|
||||
$errors->get('username'),
|
||||
['We need a username, please.']
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$errors->first('email'),
|
||||
'How do you expect us to contact you without an email?'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPassingCustomRule()
|
||||
{
|
||||
$this->v->addRule('isbanana', function($value, $input, $args) {
|
||||
return $value === 'banana';
|
||||
});
|
||||
|
||||
$this->v->validate([
|
||||
'fruit' => ['apple', 'isbanana']
|
||||
]);
|
||||
|
||||
$this->assertFalse($this->v->passes());
|
||||
}
|
||||
|
||||
public function testFailingCustomRule()
|
||||
{
|
||||
$this->v->addRule('isbanana', function($value, $input, $args) {
|
||||
return $value === 'banana';
|
||||
});
|
||||
|
||||
$this->v->validate([
|
||||
'fruit' => ['banana', 'isbanana']
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->v->passes());
|
||||
}
|
||||
|
||||
public function testMultipleCustomRules()
|
||||
{
|
||||
$this->v->addRule('isbanana', function($value, $input, $args) {
|
||||
return $value === 'banana';
|
||||
});
|
||||
|
||||
$this->v->addRule('isapple', function($value, $input, $args) {
|
||||
return $value === 'apple';
|
||||
});
|
||||
|
||||
$this->v->validate([
|
||||
'fruit_one' => ['banana', 'isbanana'],
|
||||
'fruit_two' => ['apple', 'isapple']
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->v->passes());
|
||||
}
|
||||
|
||||
public function testPassingCustomRuleWithArguments()
|
||||
{
|
||||
$this->v->addRule('isoneof', function($value, $input, $args) {
|
||||
return in_array($value, $args);
|
||||
});
|
||||
|
||||
$this->v->validate([
|
||||
'items' => ['seeds', 'isoneof(seeds, nuts, fruit)']
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->v->passes());
|
||||
}
|
||||
|
||||
public function testFailingCustomRuleWithArguments()
|
||||
{
|
||||
$this->v->addRule('isoneof', function($value, $input, $args) {
|
||||
return in_array($value, $args);
|
||||
});
|
||||
|
||||
$this->v->validate([
|
||||
'items' => ['burger', 'isoneof(seeds, nuts, fruit)']
|
||||
]);
|
||||
|
||||
$this->assertFalse($this->v->passes());
|
||||
}
|
||||
|
||||
public function testValidationWithAliases()
|
||||
{
|
||||
$this->v->addFieldMessages([
|
||||
'username_box' => [
|
||||
'required' => 'We need a username in the {field} field, please.'
|
||||
]
|
||||
]);
|
||||
|
||||
$this->v->validate([
|
||||
'username_box|Username' => ['', 'required'],
|
||||
'password' => ['secret', 'required|alpha']
|
||||
]);
|
||||
|
||||
$errors = $this->v->errors();
|
||||
|
||||
$this->assertFalse($this->v->passes());
|
||||
$this->assertTrue($this->v->fails());
|
||||
$this->assertEquals(
|
||||
$errors->first('username_box'),
|
||||
'We need a username in the Username field, please.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSkippingOtherRulesIfNotRequired()
|
||||
{
|
||||
$this->v->validate([
|
||||
'username' => ['alex', 'required|alpha'],
|
||||
'email' => ['', 'alpha|email']
|
||||
]);
|
||||
|
||||
$this->assertEmpty($this->v->errors()->all());
|
||||
}
|
||||
}
|
7
vendor/autoload.php
vendored
Executable file
7
vendor/autoload.php
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit83835b20f568ce9cd62f0e1edc75fa23::getLoader();
|
413
vendor/composer/ClassLoader.php
vendored
Executable file
413
vendor/composer/ClassLoader.php
vendored
Executable file
@ -0,0 +1,413 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0 class loader
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
||||
if ('\\' == $class[0]) {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if ($file === null && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if ($file === null) {
|
||||
// Remember that this class does not exist.
|
||||
return $this->classMap[$class] = false;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
||||
if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
9
vendor/composer/autoload_classmap.php
vendored
Executable file
9
vendor/composer/autoload_classmap.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
11
vendor/composer/autoload_files.php
vendored
Executable file
11
vendor/composer/autoload_files.php
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$vendorDir . '/danielstjules/stringy/src/Create.php',
|
||||
$vendorDir . '/illuminate/support/helpers.php',
|
||||
);
|
13
vendor/composer/autoload_namespaces.php
vendored
Executable file
13
vendor/composer/autoload_namespaces.php
vendored
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
||||
'Slim' => array($vendorDir . '/slim/slim'),
|
||||
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
|
||||
'Carbon' => array($vendorDir . '/nesbot/carbon/src'),
|
||||
);
|
18
vendor/composer/autoload_psr4.php
vendored
Executable file
18
vendor/composer/autoload_psr4.php
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Violin\\' => array($vendorDir . '/alexgarrett/violin/src'),
|
||||
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
|
||||
'Stringy\\' => array($vendorDir . '/danielstjules/stringy/src'),
|
||||
'Slim\\Views\\' => array($vendorDir . '/slim/views'),
|
||||
'Noodlehaus\\' => array($vendorDir . '/hassankhan/config/src'),
|
||||
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/support'),
|
||||
'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'),
|
||||
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
|
||||
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
|
||||
);
|
55
vendor/composer/autoload_real.php
vendored
Executable file
55
vendor/composer/autoload_real.php
vendored
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit83835b20f568ce9cd62f0e1edc75fa23
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit83835b20f568ce9cd62f0e1edc75fa23', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit83835b20f568ce9cd62f0e1edc75fa23', 'loadClassLoader'));
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequire83835b20f568ce9cd62f0e1edc75fa23($file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire83835b20f568ce9cd62f0e1edc75fa23($file)
|
||||
{
|
||||
require $file;
|
||||
}
|
711
vendor/composer/installed.json
vendored
Executable file
711
vendor/composer/installed.json
vendored
Executable file
@ -0,0 +1,711 @@
|
||||
[
|
||||
{
|
||||
"name": "slim/slim",
|
||||
"version": "2.6.2",
|
||||
"version_normalized": "2.6.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim.git",
|
||||
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim/zipball/20a02782f76830b67ae56a5c08eb1f563c351a37",
|
||||
"reference": "20a02782f76830b67ae56a5c08eb1f563c351a37",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mcrypt": "Required for HTTP cookie encryption"
|
||||
},
|
||||
"time": "2015-03-08 18:41:17",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Slim": "."
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Josh Lockhart",
|
||||
"email": "info@joshlockhart.com",
|
||||
"homepage": "http://www.joshlockhart.com/"
|
||||
}
|
||||
],
|
||||
"description": "Slim Framework, a PHP micro framework",
|
||||
"homepage": "http://github.com/codeguy/Slim",
|
||||
"keywords": [
|
||||
"microframework",
|
||||
"rest",
|
||||
"router"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "slim/views",
|
||||
"version": "0.1.3",
|
||||
"version_normalized": "0.1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/slimphp/Slim-Views.git",
|
||||
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
|
||||
"reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"slim/slim": ">=2.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"smarty/smarty": "Smarty templating system",
|
||||
"twig/twig": "Twig templating system"
|
||||
},
|
||||
"time": "2014-12-09 23:48:51",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Slim\\Views\\": "./"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Josh Lockhart",
|
||||
"email": "info@joshlockhart.com",
|
||||
"homepage": "http://www.joshlockhart.com/"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Smith",
|
||||
"email": "a.smith@silentworks.co.uk",
|
||||
"homepage": "http://thoughts.silentworks.co.uk/"
|
||||
}
|
||||
],
|
||||
"description": "Smarty and Twig View Parser package for the Slim Framework",
|
||||
"homepage": "http://github.com/codeguy/Slim-Views",
|
||||
"keywords": [
|
||||
"extensions",
|
||||
"slimphp",
|
||||
"templating"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.18.2",
|
||||
"version_normalized": "1.18.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.7"
|
||||
},
|
||||
"time": "2015-06-06 23:31:24",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.18-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Twig_": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Armin Ronacher",
|
||||
"email": "armin.ronacher@active-4.com",
|
||||
"role": "Project Founder"
|
||||
},
|
||||
{
|
||||
"name": "Twig Team",
|
||||
"homepage": "http://twig.sensiolabs.org/contributors",
|
||||
"role": "Contributors"
|
||||
}
|
||||
],
|
||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||
"homepage": "http://twig.sensiolabs.org",
|
||||
"keywords": [
|
||||
"templating"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v2.7.0",
|
||||
"version_normalized": "2.7.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Translation.git",
|
||||
"reference": "cc1907bbeacfcc703c031b67545400d6e7d1eb79"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/cc1907bbeacfcc703c031b67545400d6e7d1eb79",
|
||||
"reference": "cc1907bbeacfcc703c031b67545400d6e7d1eb79",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<2.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~2.7",
|
||||
"symfony/intl": "~2.3",
|
||||
"symfony/phpunit-bridge": "~2.7",
|
||||
"symfony/yaml": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "To use logging capability in translator",
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"time": "2015-05-29 14:44:44",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Translation\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "https://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.19.0",
|
||||
"version_normalized": "1.19.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "68868e0b02d2d803d0052a59d4e5003cccf87320"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/68868e0b02d2d803d0052a59d4e5003cccf87320",
|
||||
"reference": "68868e0b02d2d803d0052a59d4e5003cccf87320",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"symfony/translation": "~2.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"time": "2015-05-09 03:23:44",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Carbon": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brian Nesbitt",
|
||||
"email": "brian@nesbot.com",
|
||||
"homepage": "http://nesbot.com"
|
||||
}
|
||||
],
|
||||
"description": "A simple API extension for DateTime.",
|
||||
"homepage": "http://carbon.nesbot.com",
|
||||
"keywords": [
|
||||
"date",
|
||||
"datetime",
|
||||
"time"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
"version": "1.9.0",
|
||||
"version_normalized": "1.9.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danielstjules/Stringy.git",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"time": "2015-02-10 06:19:18",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Stringy\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/Create.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Daniel St. Jules",
|
||||
"email": "danielst.jules@gmail.com",
|
||||
"homepage": "http://www.danielstjules.com"
|
||||
}
|
||||
],
|
||||
"description": "A string manipulation library with multibyte support",
|
||||
"homepage": "https://github.com/danielstjules/Stringy",
|
||||
"keywords": [
|
||||
"UTF",
|
||||
"helpers",
|
||||
"manipulation",
|
||||
"methods",
|
||||
"multibyte",
|
||||
"string",
|
||||
"utf-8",
|
||||
"utility",
|
||||
"utils"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "v1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/inflector.git",
|
||||
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
|
||||
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"time": "2014-12-20 21:24:13",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Inflector\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"inflection",
|
||||
"pluralize",
|
||||
"singularize",
|
||||
"string"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "illuminate/contracts",
|
||||
"version": "v5.0.0",
|
||||
"version_normalized": "5.0.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/contracts.git",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"time": "2015-01-30 16:27:08",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Contracts\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Contracts package."
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v5.0.28",
|
||||
"version_normalized": "5.0.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/support.git",
|
||||
"reference": "b6d68e1f2a7053bf4c755c5e6b15fcfb700e14e7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/b6d68e1f2a7053bf4c755c5e6b15fcfb700e14e7",
|
||||
"reference": "b6d68e1f2a7053bf4c755c5e6b15fcfb700e14e7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"danielstjules/stringy": "~1.8",
|
||||
"doctrine/inflector": "~1.0",
|
||||
"ext-mbstring": "*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)."
|
||||
},
|
||||
"time": "2015-04-15 19:26:55",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Support\\": ""
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Support package.",
|
||||
"homepage": "http://laravel.com"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"version": "v5.0.28",
|
||||
"version_normalized": "5.0.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/container.git",
|
||||
"reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/a11c01c1d8b6941bd7ef2f104749ada5e34f146e",
|
||||
"reference": "a11c01c1d8b6941bd7ef2f104749ada5e34f146e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"time": "2015-03-25 17:06:14",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Container\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Container package.",
|
||||
"homepage": "http://laravel.com"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/database",
|
||||
"version": "v5.0.28",
|
||||
"version_normalized": "5.0.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/database.git",
|
||||
"reference": "dd7bd24a0240607e1de36cfe8d43335653d1536c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/dd7bd24a0240607e1de36cfe8d43335653d1536c",
|
||||
"reference": "dd7bd24a0240607e1de36cfe8d43335653d1536c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "5.0.*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"nesbot/carbon": "~1.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).",
|
||||
"illuminate/console": "Required to use the database commands (5.0.*).",
|
||||
"illuminate/events": "Required to use the observers with Eloquent (5.0.*).",
|
||||
"illuminate/filesystem": "Required to use the migrations (5.0.*)."
|
||||
},
|
||||
"time": "2015-04-19 09:23:09",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Database\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Database package.",
|
||||
"homepage": "http://laravel.com",
|
||||
"keywords": [
|
||||
"database",
|
||||
"laravel",
|
||||
"orm",
|
||||
"sql"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "hassankhan/config",
|
||||
"version": "0.8.2",
|
||||
"version_normalized": "0.8.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/hassankhan/config.git",
|
||||
"reference": "42ba051954745b565306f0f82c57814f54579f8d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/hassankhan/config/zipball/42ba051954745b565306f0f82c57814f54579f8d",
|
||||
"reference": "42ba051954745b565306f0f82c57814f54579f8d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"scrutinizer/ocular": "~1.1",
|
||||
"squizlabs/php_codesniffer": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/yaml": "~2.5"
|
||||
},
|
||||
"time": "2015-03-21 11:21:39",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Noodlehaus\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Hassan Khan",
|
||||
"homepage": "http://hassankhan.me/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files",
|
||||
"homepage": "http://hassankhan.me/config/",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"ini",
|
||||
"json",
|
||||
"microphp",
|
||||
"unframework",
|
||||
"xml",
|
||||
"yaml",
|
||||
"yml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "alexgarrett/violin",
|
||||
"version": "2.2.2",
|
||||
"version_normalized": "2.2.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/alexgarrett/violin.git",
|
||||
"reference": "92d0ee5d0e7cc1703fe937772c313721fdb86cdc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/alexgarrett/violin/zipball/92d0ee5d0e7cc1703fe937772c313721fdb86cdc",
|
||||
"reference": "92d0ee5d0e7cc1703fe937772c313721fdb86cdc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.5",
|
||||
"squizlabs/php_codesniffer": "2.1.*"
|
||||
},
|
||||
"time": "2015-04-11 22:58:34",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Violin\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex Garrett",
|
||||
"email": "alex@codecourse.com",
|
||||
"homepage": "http://itsmealex.com"
|
||||
}
|
||||
],
|
||||
"description": "Violin is an easy to use, highly customisable PHP validator.",
|
||||
"homepage": "https://github.com/alexgarrett/violin",
|
||||
"keywords": [
|
||||
"validation"
|
||||
]
|
||||
}
|
||||
]
|
110
vendor/danielstjules/stringy/CHANGELOG.md
vendored
Executable file
110
vendor/danielstjules/stringy/CHANGELOG.md
vendored
Executable file
@ -0,0 +1,110 @@
|
||||
### 1.9.0 (2015-02-09)
|
||||
|
||||
* Added hasUpperCase and hasLowerCase
|
||||
* Added $removeUnsupported parameter to toAscii()
|
||||
* Improved toAscii support with additional Unicode spaces, Vietnamese chars,
|
||||
and numerous other characters
|
||||
* Separated the charsArray from toAscii as a protected method that may be
|
||||
extended by inheriting classes
|
||||
* Chars array is cached for better performance
|
||||
|
||||
### 1.8.1 (2015-01-08)
|
||||
|
||||
* Optimized chars()
|
||||
* Added "ä Ä Ö Ü"" in toAscii()
|
||||
* Added support for Unicode spaces in toAscii()
|
||||
* Replaced instances of self::create() with static::create()
|
||||
* Added missing test cases for safeTruncate() and longestCommonSuffix()
|
||||
* Updated Stringy\create() to avoid collision when it already exists
|
||||
|
||||
### 1.8.0 (2015-01-03)
|
||||
|
||||
* Listed ext-mbstring in composer.json
|
||||
* Added Stringy\create function for PHP 5.6
|
||||
|
||||
### 1.7.0 (2014-10-14)
|
||||
|
||||
* Added containsAll and containsAny
|
||||
* Light cleanup
|
||||
|
||||
### 1.6.0 (2014-09-14)
|
||||
|
||||
* Added toTitleCase
|
||||
|
||||
### 1.5.2 (2014-07-09)
|
||||
|
||||
* Announced support for HHVM
|
||||
|
||||
### 1.5.1 (2014-04-19)
|
||||
|
||||
* Fixed toAscii() failing to remove remaining non-ascii characters
|
||||
* Updated slugify() to treat dash and underscore as delimiters by default
|
||||
* Updated slugify() to remove leading and trailing delimiter, if present
|
||||
|
||||
### 1.5.0 (2014-03-19)
|
||||
|
||||
* Made both str and encoding protected, giving property access to subclasses
|
||||
* Added getEncoding()
|
||||
* Fixed isJSON() giving false negatives
|
||||
* Cleaned up and simplified: replace(), collapseWhitespace(), underscored(),
|
||||
dasherize(), pad(), padLeft(), padRight() and padBoth()
|
||||
* Fixed handling consecutive invalid chars in slugify()
|
||||
* Removed conflicting hard sign transliteration in toAscii()
|
||||
|
||||
### 1.4.0 (2014-02-12)
|
||||
|
||||
* Implemented the IteratorAggregate interface, added chars()
|
||||
* Renamed count() to countSubstr()
|
||||
* Updated count() to implement Countable interface
|
||||
* Implemented the ArrayAccess interface with positive and negative indices
|
||||
* Switched from PSR-0 to PSR-4 autoloading
|
||||
|
||||
### 1.3.0 (2013-12-16)
|
||||
|
||||
* Additional Bulgarian support for toAscii
|
||||
* str property made private
|
||||
* Constructor casts first argument to string
|
||||
* Constructor throws an InvalidArgumentException when given an array
|
||||
* Constructor throws an InvalidArgumentException when given an object without
|
||||
a __toString method
|
||||
|
||||
### 1.2.2 (2013-12-04)
|
||||
|
||||
* Updated create function to use late static binding
|
||||
* Added optional $replacement param to slugify
|
||||
|
||||
### 1.2.1 (2013-10-11)
|
||||
|
||||
* Cleaned up tests
|
||||
* Added homepage to composer.json
|
||||
|
||||
### 1.2.0 (2013-09-15)
|
||||
|
||||
* Fixed pad's use of InvalidArgumentException
|
||||
* Fixed replace(). It now correctly treats regex special chars as normal chars
|
||||
* Added additional Cyrillic letters to toAscii
|
||||
* Added $caseSensitive to contains() and count()
|
||||
* Added toLowerCase()
|
||||
* Added toUpperCase()
|
||||
* Added regexReplace()
|
||||
|
||||
### 1.1.0 (2013-08-31)
|
||||
|
||||
* Fix for collapseWhitespace()
|
||||
* Added isHexadecimal()
|
||||
* Added constructor to Stringy\Stringy
|
||||
* Added isSerialized()
|
||||
* Added isJson()
|
||||
|
||||
### 1.0.0 (2013-08-1)
|
||||
|
||||
* 1.0.0 release
|
||||
* Added test coverage for Stringy::create and method chaining
|
||||
* Added tests for returned type
|
||||
* Fixed StaticStringy::replace(). It was returning a Stringy object instead of string
|
||||
* Renamed standardize() to the more appropriate toAscii()
|
||||
* Cleaned up comments and README
|
||||
|
||||
### 1.0.0-rc.1 (2013-07-28)
|
||||
|
||||
* Release candidate
|
19
vendor/danielstjules/stringy/LICENSE.txt
vendored
Executable file
19
vendor/danielstjules/stringy/LICENSE.txt
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
Copyright (C) 2013 Daniel St. Jules
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
1077
vendor/danielstjules/stringy/README.md
vendored
Executable file
1077
vendor/danielstjules/stringy/README.md
vendored
Executable file
File diff suppressed because it is too large
Load Diff
35
vendor/danielstjules/stringy/composer.json
vendored
Executable file
35
vendor/danielstjules/stringy/composer.json
vendored
Executable file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
"description": "A string manipulation library with multibyte support",
|
||||
"keywords": [
|
||||
"multibyte", "string", "manipulation", "utility", "methods", "utf-8",
|
||||
"helpers", "utils", "utf"
|
||||
],
|
||||
"homepage": "https://github.com/danielstjules/Stringy",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Daniel St. Jules",
|
||||
"email": "danielst.jules@gmail.com",
|
||||
"homepage": "http://www.danielstjules.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"support": {
|
||||
"issues": "https://github.com/danielstjules/Stringy/issues",
|
||||
"source": "https://github.com/danielstjules/Stringy"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Stringy\\": "src/" },
|
||||
"files": ["src/Create.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [ "tests" ]
|
||||
}
|
||||
}
|
14
vendor/danielstjules/stringy/phpunit.xml.dist
vendored
Executable file
14
vendor/danielstjules/stringy/phpunit.xml.dist
vendored
Executable file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
<testsuites>
|
||||
<testsuite name="Stringy">
|
||||
<file>tests/CommonTest.php</file>
|
||||
<file>tests/StringyTest.php</file>
|
||||
<file>tests/StaticStringyTest.php</file>
|
||||
<file phpVersion="5.6.0">tests/CreateTest.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
19
vendor/danielstjules/stringy/src/Create.php
vendored
Executable file
19
vendor/danielstjules/stringy/src/Create.php
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Stringy;
|
||||
|
||||
if (!function_exists('Stringy\create')) {
|
||||
/**
|
||||
* Creates a Stringy object and returns it on success.
|
||||
*
|
||||
* @param mixed $str Value to modify, after being cast to string
|
||||
* @param string $encoding The character encoding
|
||||
* @return Stringy A Stringy object
|
||||
* @throws \InvalidArgumentException if an array or object without a
|
||||
* __toString method is passed as the first argument
|
||||
*/
|
||||
function create($str, $encoding = null)
|
||||
{
|
||||
return new Stringy($str, $encoding);
|
||||
}
|
||||
}
|
869
vendor/danielstjules/stringy/src/StaticStringy.php
vendored
Executable file
869
vendor/danielstjules/stringy/src/StaticStringy.php
vendored
Executable file
@ -0,0 +1,869 @@
|
||||
<?php
|
||||
|
||||
namespace Stringy;
|
||||
|
||||
class StaticStringy
|
||||
{
|
||||
/**
|
||||
* Returns an array consisting of the characters in the string.
|
||||
*
|
||||
* @param string $str String for which to return the chars
|
||||
* @param string $encoding The character encoding
|
||||
* @return array An array of string chars
|
||||
*/
|
||||
public static function chars($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->chars();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first character of the supplied string to upper case.
|
||||
*
|
||||
* @param string $str String to modify
|
||||
* @param string $encoding The character encoding
|
||||
* @return string String with the first character being upper case
|
||||
*/
|
||||
public static function upperCaseFirst($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->upperCaseFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first character of the supplied string to lower case.
|
||||
*
|
||||
* @param string $str String to modify
|
||||
* @param string $encoding The character encoding
|
||||
* @return string String with the first character being lower case
|
||||
*/
|
||||
public static function lowerCaseFirst($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->lowerCaseFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a camelCase version of the string. Trims surrounding spaces,
|
||||
* capitalizes letters following digits, spaces, dashes and underscores,
|
||||
* and removes spaces, dashes, as well as underscores.
|
||||
*
|
||||
* @param string $str String to convert to camelCase
|
||||
* @param string $encoding The character encoding
|
||||
* @return string String in camelCase
|
||||
*/
|
||||
public static function camelize($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->camelize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an UpperCamelCase version of the supplied string. It trims
|
||||
* surrounding spaces, capitalizes letters following digits, spaces, dashes
|
||||
* and underscores, and removes spaces, dashes, underscores.
|
||||
*
|
||||
* @param string $str String to convert to UpperCamelCase
|
||||
* @param string $encoding The character encoding
|
||||
* @return string String in UpperCamelCase
|
||||
*/
|
||||
public static function upperCamelize($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->upperCamelize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a lowercase and trimmed string separated by dashes. Dashes are
|
||||
* inserted before uppercase characters (with the exception of the first
|
||||
* character of the string), and in place of spaces as well as underscores.
|
||||
*
|
||||
* @param string $str String to convert
|
||||
* @param string $encoding The character encoding
|
||||
* @return string Dasherized string
|
||||
*/
|
||||
public static function dasherize($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->dasherize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a lowercase and trimmed string separated by underscores.
|
||||
* Underscores are inserted before uppercase characters (with the exception
|
||||
* of the first character of the string), and in place of spaces as well as
|
||||
* dashes.
|
||||
*
|
||||
* @param string $str String to convert
|
||||
* @param string $encoding The character encoding
|
||||
* @return string Underscored string
|
||||
*/
|
||||
public static function underscored($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->underscored();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a case swapped version of the string.
|
||||
*
|
||||
* @param string $str String to swap case
|
||||
* @param string $encoding The character encoding
|
||||
* @return string String with each character's case swapped
|
||||
*/
|
||||
public static function swapCase($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->swapCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a trimmed string with the first letter of each word capitalized.
|
||||
* Ignores the case of other letters, preserving any acronyms. Also accepts
|
||||
* an array, $ignore, allowing you to list words not to be capitalized.
|
||||
*
|
||||
* @param string $str String to titleize
|
||||
* @param string $encoding The character encoding
|
||||
* @param array $ignore An array of words not to capitalize
|
||||
* @return string Titleized string
|
||||
*/
|
||||
public static function titleize($str, $ignore = null, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->titleize($ignore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Capitalizes the first word of the string, replaces underscores with
|
||||
* spaces, and strips '_id'.
|
||||
*
|
||||
* @param string $str String to humanize
|
||||
* @param string $encoding The character encoding
|
||||
* @return string A humanized string
|
||||
*/
|
||||
public static function humanize($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->humanize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with smart quotes, ellipsis characters, and dashes from
|
||||
* Windows-1252 (commonly used in Word documents) replaced by their ASCII
|
||||
* equivalents.
|
||||
*
|
||||
* @param string $str String to remove special chars
|
||||
* @return string String with those characters removed
|
||||
*/
|
||||
public static function tidy($str)
|
||||
{
|
||||
return (string) Stringy::create($str)->tidy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims the string and replaces consecutive whitespace characters with a
|
||||
* single space. This includes tabs and newline characters, as well as
|
||||
* multibyte whitespace such as the thin space and ideographic space.
|
||||
*
|
||||
* @param string $str The string to cleanup whitespace
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The trimmed string with condensed whitespace
|
||||
*/
|
||||
public static function collapseWhitespace($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->collapseWhitespace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ASCII version of the string. A set of non-ASCII characters are
|
||||
* replaced with their closest ASCII counterparts, and the rest are removed
|
||||
* unless instructed otherwise.
|
||||
*
|
||||
* @param string $str A string with non-ASCII characters
|
||||
* @param bool $removeUnsupported Whether or not to remove the
|
||||
* unsupported characters
|
||||
* @return string A string containing only ASCII characters
|
||||
*/
|
||||
public static function toAscii($str, $removeUnsupported = true)
|
||||
{
|
||||
return (string) Stringy::create($str)->toAscii($removeUnsupported);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads the string to a given length with $padStr. If length is less than
|
||||
* or equal to the length of the string, no padding takes places. The
|
||||
* default string used for padding is a space, and the default type (one of
|
||||
* 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException
|
||||
* if $padType isn't one of those 3 values.
|
||||
*
|
||||
* @param string $str String to pad
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $padType One of 'left', 'right', 'both'
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The padded string
|
||||
* @throws \InvalidArgumentException If $padType isn't one of 'right',
|
||||
* 'left' or 'both'
|
||||
*/
|
||||
public static function pad($str, $length, $padStr = ' ', $padType = 'right',
|
||||
$encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->pad($length, $padStr, $padType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new string of a given length such that the beginning of the
|
||||
* string is padded. Alias for pad() with a $padType of 'left'.
|
||||
*
|
||||
* @param string $str String to pad
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The padded string
|
||||
*/
|
||||
public static function padLeft($str, $length, $padStr = ' ', $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->padLeft($length, $padStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new string of a given length such that the end of the string
|
||||
* is padded. Alias for pad() with a $padType of 'right'.
|
||||
*
|
||||
* @param string $str String to pad
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The padded string
|
||||
*/
|
||||
public static function padRight($str, $length, $padStr = ' ', $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->padRight($length, $padStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new string of a given length such that both sides of the
|
||||
* string are padded. Alias for pad() with a $padType of 'both'.
|
||||
*
|
||||
* @param string $str String to pad
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The padded string
|
||||
*/
|
||||
public static function padBoth($str, $length, $padStr = ' ', $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->padBoth($length, $padStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string begins with $substring, false otherwise. By
|
||||
* default, the comparison is case-sensitive, but can be made insensitive
|
||||
* by setting $caseSensitive to false.
|
||||
*
|
||||
* @param string $str String to check the start of
|
||||
* @param string $substring The substring to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str starts with $substring
|
||||
*/
|
||||
public static function startsWith($str, $substring, $caseSensitive = true,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)
|
||||
->startsWith($substring, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string ends with $substring, false otherwise. By
|
||||
* default, the comparison is case-sensitive, but can be made insensitive
|
||||
* by setting $caseSensitive to false.
|
||||
*
|
||||
* @param string $str String to check the end of
|
||||
* @param string $substring The substring to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str ends with $substring
|
||||
*/
|
||||
public static function endsWith($str, $substring, $caseSensitive = true,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)
|
||||
->endsWith($substring, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts each tab in the string to some number of spaces, as defined by
|
||||
* $tabLength. By default, each tab is converted to 4 consecutive spaces.
|
||||
*
|
||||
* @param string $str String to convert tabs to spaces
|
||||
* @param int $tabLength Number of spaces to replace each tab with
|
||||
* @return string String with tabs switched to spaces
|
||||
*/
|
||||
public static function toSpaces($str, $tabLength = 4)
|
||||
{
|
||||
return (string) Stringy::create($str)->toSpaces($tabLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts each occurrence of some consecutive number of spaces, as
|
||||
* defined by $tabLength, to a tab. By default, each 4 consecutive spaces
|
||||
* are converted to a tab.
|
||||
*
|
||||
* @param string $str String to convert spaces to tabs
|
||||
* @param int $tabLength Number of spaces to replace with a tab
|
||||
* @return string String with spaces switched to tabs
|
||||
*/
|
||||
public static function toTabs($str, $tabLength = 4)
|
||||
{
|
||||
return (string) Stringy::create($str)->toTabs($tabLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all characters in the string to lowercase. An alias for PHP's
|
||||
* mb_strtolower().
|
||||
*
|
||||
* @param string $str String to convert case
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The lowercase string
|
||||
*/
|
||||
public static function toLowerCase($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first character of each word in the string to uppercase.
|
||||
*
|
||||
* @param string $str String to convert case
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The title-cased string
|
||||
*/
|
||||
public static function toTitleCase($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->toTitleCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all characters in the string to uppercase. An alias for PHP's
|
||||
* mb_strtoupper().
|
||||
*
|
||||
* @param string $str String to convert case
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The uppercase string
|
||||
*/
|
||||
public static function toUpperCase($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the string into an URL slug. This includes replacing non-ASCII
|
||||
* characters with their closest ASCII equivalents, removing remaining
|
||||
* non-ASCII and non-alphanumeric characters, and replacing whitespace with
|
||||
* $replacement. The replacement defaults to a single dash, and the string
|
||||
* is also converted to lowercase.
|
||||
*
|
||||
* @param string $str Text to transform into an URL slug
|
||||
* @param string $replacement The string used to replace whitespace
|
||||
* @return string The corresponding URL slug
|
||||
*/
|
||||
public static function slugify($str, $replacement = '-')
|
||||
{
|
||||
return (string) Stringy::create($str)->slugify($replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains $needle, false otherwise. By default,
|
||||
* the comparison is case-sensitive, but can be made insensitive by setting
|
||||
* $caseSensitive to false.
|
||||
*
|
||||
* @param string $haystack String being checked
|
||||
* @param string $needle Substring to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $haystack contains $needle
|
||||
*/
|
||||
public static function contains($haystack, $needle, $caseSensitive = true,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($haystack, $encoding)
|
||||
->contains($needle, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains any $needles, false otherwise. By
|
||||
* default, the comparison is case-sensitive, but can be made insensitive
|
||||
* by setting $caseSensitive to false.
|
||||
*
|
||||
* @param string $haystack String being checked
|
||||
* @param array $needles Substrings to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $haystack contains any $needles
|
||||
*/
|
||||
public static function containsAny($haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
return Stringy::create($haystack, $encoding)
|
||||
->containsAny($needles, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains all $needles, false otherwise. By
|
||||
* default, the comparison is case-sensitive, but can be made insensitive
|
||||
* by setting $caseSensitive to false.
|
||||
*
|
||||
* @param string $haystack String being checked
|
||||
* @param array $needles Substrings to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $haystack contains all $needles
|
||||
*/
|
||||
public static function containsAll($haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
return Stringy::create($haystack, $encoding)
|
||||
->containsAll($needles, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Surrounds a string with the given substring.
|
||||
*
|
||||
* @param string $str The string to surround
|
||||
* @param string $substring The substring to add to both sides
|
||||
* @return string The string with the substring prepended and appended
|
||||
*/
|
||||
public static function surround($str, $substring)
|
||||
{
|
||||
return (string) Stringy::create($str)->surround($substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts $substring into the string at the $index provided.
|
||||
*
|
||||
* @param string $str String to insert into
|
||||
* @param string $substring String to be inserted
|
||||
* @param int $index The index at which to insert the substring
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The resulting string after the insertion
|
||||
*/
|
||||
public static function insert($str, $substring, $index, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->insert($substring, $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the string to a given length. If $substring is provided, and
|
||||
* truncating occurs, the string is further truncated so that the substring
|
||||
* may be appended without exceeding the desired length.
|
||||
*
|
||||
* @param string $str String to truncate
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The resulting string after truncating
|
||||
*/
|
||||
public static function truncate($str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->truncate($length, $substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the string to a given length, while ensuring that it does not
|
||||
* split words. If $substring is provided, and truncating occurs, the
|
||||
* string is further truncated so that the substring may be appended without
|
||||
* exceeding the desired length.
|
||||
*
|
||||
* @param string $str String to truncate
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The resulting string after truncating
|
||||
*/
|
||||
public static function safeTruncate($str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->safeTruncate($length, $substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reversed string. A multibyte version of strrev().
|
||||
*
|
||||
* @param string $str String to reverse
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The reversed string
|
||||
*/
|
||||
public static function reverse($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* A multibyte str_shuffle() function. It returns a string with its
|
||||
* characters in random order.
|
||||
*
|
||||
* @param string $str String to shuffle
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The shuffled string
|
||||
*/
|
||||
public static function shuffle($str, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->shuffle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the trimmed string. An alias for PHP's trim() function.
|
||||
*
|
||||
* @param string $str String to trim
|
||||
* @return string Trimmed $str
|
||||
*/
|
||||
public static function trim($str)
|
||||
{
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the longest common prefix between the string and $otherStr.
|
||||
*
|
||||
* @param string $str First string for comparison
|
||||
* @param string $otherStr Second string for comparison
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The longest common prefix
|
||||
*/
|
||||
public static function longestCommonPrefix($str, $otherStr, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->longestCommonPrefix($otherStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the longest common suffix between the string and $otherStr.
|
||||
*
|
||||
* @param string $str First string for comparison
|
||||
* @param string $otherStr Second string for comparison
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The longest common suffix
|
||||
*/
|
||||
public static function longestCommonSuffix($str, $otherStr, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->longestCommonSuffix($otherStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the longest common substring between the string and $otherStr.
|
||||
* In the case of ties, it returns that which occurs first.
|
||||
*
|
||||
* @param string $str First string for comparison
|
||||
* @param string $otherStr Second string for comparison
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The longest common substring
|
||||
*/
|
||||
public static function longestCommonSubstring($str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->longestCommonSubstring($otherStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the string. An alias for PHP's mb_strlen() function.
|
||||
*
|
||||
* @param string $str The string to get the length of
|
||||
* @param string $encoding The character encoding
|
||||
* @return int The number of characters in $str given the encoding
|
||||
*/
|
||||
public static function length($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->length();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the substring beginning at $start with the specified $length.
|
||||
* It differs from the mb_substr() function in that providing a $length of
|
||||
* null will return the rest of the string, rather than an empty string.
|
||||
*
|
||||
* @param string $str The string to get the length of
|
||||
* @param int $start Position of the first character to use
|
||||
* @param int $length Maximum number of characters used
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The substring of $str
|
||||
*/
|
||||
public static function substr($str, $start, $length = null, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->substr($start, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character at $index, with indexes starting at 0.
|
||||
*
|
||||
* @param string $str The string from which to get the char
|
||||
* @param int $index Position of the character
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The character at $index
|
||||
*/
|
||||
public static function at($str, $index, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->at($index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first $n characters of the string.
|
||||
*
|
||||
* @param string $str The string from which to get the substring
|
||||
* @param int $n Number of chars to retrieve from the start
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The first $n characters
|
||||
*/
|
||||
public static function first($str, $n, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->first($n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last $n characters of the string.
|
||||
*
|
||||
* @param string $str The string from which to get the substring
|
||||
* @param int $n Number of chars to retrieve from the end
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The last $n characters
|
||||
*/
|
||||
public static function last($str, $n, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->last($n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the string begins with $substring. If it doesn't, it's
|
||||
* prepended.
|
||||
*
|
||||
* @param string $str The string to modify
|
||||
* @param string $substring The substring to add if not present
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The string prefixed by the $substring
|
||||
*/
|
||||
public static function ensureLeft($str, $substring, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->ensureLeft($substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the string begins with $substring. If it doesn't, it's
|
||||
* appended.
|
||||
*
|
||||
* @param string $str The string to modify
|
||||
* @param string $substring The substring to add if not present
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The string suffixed by the $substring
|
||||
*/
|
||||
public static function ensureRight($str, $substring, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->ensureRight($substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new string with the prefix $substring removed, if present.
|
||||
*
|
||||
* @param string $str String from which to remove the prefix
|
||||
* @param string $substring The prefix to remove
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The string without the prefix $substring
|
||||
*/
|
||||
public static function removeLeft($str, $substring, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->removeLeft($substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new string with the suffix $substring removed, if present.
|
||||
*
|
||||
* @param string $str String from which to remove the suffix
|
||||
* @param string $substring The suffix to remove
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The string without the suffix $substring
|
||||
*/
|
||||
public static function removeRight($str, $substring, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)->removeRight($substring);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains a lower case char, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains a lower case character.
|
||||
*/
|
||||
public static function hasLowerCase($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->hasLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains an upper case char, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains an upper case character.
|
||||
*/
|
||||
public static function hasUpperCase($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->hasUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only alphabetic chars, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only alphabetic chars
|
||||
*/
|
||||
public static function isAlpha($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isAlpha();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only alphabetic and numeric chars,
|
||||
* false otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only alphanumeric chars
|
||||
*/
|
||||
public static function isAlphanumeric($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isAlphanumeric();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only whitespace chars, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only whitespace characters
|
||||
*/
|
||||
public static function isBlank($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string is JSON, false otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str is JSON
|
||||
*/
|
||||
public static function isJson($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only lower case chars, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only lower case characters
|
||||
*/
|
||||
public static function isLowerCase($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string is serialized, false otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str is serialized
|
||||
*/
|
||||
public static function isSerialized($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isSerialized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only upper case chars, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only upper case characters
|
||||
*/
|
||||
public static function isUpperCase($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the string contains only hexadecimal chars, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param string $str String to check
|
||||
* @param string $encoding The character encoding
|
||||
* @return bool Whether or not $str contains only hexadecimal characters
|
||||
*/
|
||||
public static function isHexadecimal($str, $encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->isHexadecimal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of occurrences of $substring in the given string.
|
||||
* By default, the comparison is case-sensitive, but can be made insensitive
|
||||
* by setting $caseSensitive to false.
|
||||
*
|
||||
* @param string $str The string to search through
|
||||
* @param string $substring The substring to search for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @param string $encoding The character encoding
|
||||
* @return int The number of $substring occurrences
|
||||
*/
|
||||
public static function countSubstr($str, $substring, $caseSensitive = true,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)
|
||||
->countSubstr($substring, $caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of $search in $str by $replacement.
|
||||
*
|
||||
* @param string $str The haystack to search through
|
||||
* @param string $search The needle to search for
|
||||
* @param string $replacement The string to replace with
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The resulting string after the replacements
|
||||
*/
|
||||
public static function replace($str, $search, $replacement, $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->replace($search, $replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of $pattern in $str by $replacement. An alias
|
||||
* for mb_ereg_replace(). Note that the 'i' option with multibyte patterns
|
||||
* in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support
|
||||
* in the bundled version of Oniguruma in PHP 5.3.
|
||||
*
|
||||
* @param string $str The haystack to search through
|
||||
* @param string $pattern The regular expression pattern
|
||||
* @param string $replacement The string to replace with
|
||||
* @param string $options Matching conditions to be used
|
||||
* @param string $encoding The character encoding
|
||||
* @return string The resulting string after the replacements
|
||||
*/
|
||||
public static function regexReplace($str, $pattern, $replacement,
|
||||
$options = 'msr', $encoding = null)
|
||||
{
|
||||
return (string) Stringy::create($str, $encoding)
|
||||
->regexReplace($pattern, $replacement, $options, $encoding);
|
||||
}
|
||||
}
|
1464
vendor/danielstjules/stringy/src/Stringy.php
vendored
Executable file
1464
vendor/danielstjules/stringy/src/Stringy.php
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1026
vendor/danielstjules/stringy/tests/CommonTest.php
vendored
Executable file
1026
vendor/danielstjules/stringy/tests/CommonTest.php
vendored
Executable file
File diff suppressed because it is too large
Load Diff
16
vendor/danielstjules/stringy/tests/CreateTest.php
vendored
Executable file
16
vendor/danielstjules/stringy/tests/CreateTest.php
vendored
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/Create.php';
|
||||
|
||||
use function Stringy\create as s;
|
||||
|
||||
class CreateTestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$stringy = s('foo bar', 'UTF-8');
|
||||
$this->assertInstanceOf('Stringy\Stringy', $stringy);
|
||||
$this->assertEquals('foo bar', (string) $stringy);
|
||||
$this->assertEquals('UTF-8', $stringy->getEncoding());
|
||||
}
|
||||
}
|
650
vendor/danielstjules/stringy/tests/StaticStringyTest.php
vendored
Executable file
650
vendor/danielstjules/stringy/tests/StaticStringyTest.php
vendored
Executable file
@ -0,0 +1,650 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/StaticStringy.php';
|
||||
|
||||
use Stringy\StaticStringy as S;
|
||||
|
||||
class StaticStringyTestCase extends CommonTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider charsProvider()
|
||||
*/
|
||||
public function testChars($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::chars($str, $encoding);
|
||||
$this->assertInternalType('array', $result);
|
||||
foreach ($result as $char) {
|
||||
$this->assertInternalType('string', $char);
|
||||
}
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upperCaseFirstProvider()
|
||||
*/
|
||||
public function testUpperCaseFirst($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::upperCaseFirst($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lowerCaseFirstProvider()
|
||||
*/
|
||||
public function testLowerCaseFirst($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::lowerCaseFirst($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider camelizeProvider()
|
||||
*/
|
||||
public function testCamelize($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::camelize($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upperCamelizeProvider()
|
||||
*/
|
||||
public function testUpperCamelize($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::upperCamelize($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dasherizeProvider()
|
||||
*/
|
||||
public function testDasherize($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::dasherize($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider underscoredProvider()
|
||||
*/
|
||||
public function testUnderscored($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::underscored($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider swapCaseProvider()
|
||||
*/
|
||||
public function testSwapCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::swapCase($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider titleizeProvider()
|
||||
*/
|
||||
public function testTitleize($expected, $str, $ignore = null,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::titleize($str, $ignore, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider humanizeProvider()
|
||||
*/
|
||||
public function testHumanize($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::humanize($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider tidyProvider()
|
||||
*/
|
||||
public function testTidy($expected, $str)
|
||||
{
|
||||
$result = S::tidy($str);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider collapseWhitespaceProvider()
|
||||
*/
|
||||
public function testCollapseWhitespace($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::collapseWhitespace($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toAsciiProvider()
|
||||
*/
|
||||
public function testToAscii($expected, $str, $removeUnsupported = true)
|
||||
{
|
||||
$result = S::toAscii($str, $removeUnsupported);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padProvider()
|
||||
*/
|
||||
public function testPad($expected, $str, $length, $padStr = ' ',
|
||||
$padType = 'right', $encoding = null)
|
||||
{
|
||||
$result = S::pad($str, $length, $padStr, $padType, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testPadException()
|
||||
{
|
||||
$result = S::pad('string', 5, 'foo', 'bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padLeftProvider()
|
||||
*/
|
||||
public function testPadLeft($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::padLeft($str, $length, $padStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padRightProvider()
|
||||
*/
|
||||
public function testPadRight($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::padRight($str, $length, $padStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padBothProvider()
|
||||
*/
|
||||
public function testPadBoth($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::padBoth($str, $length, $padStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider startsWithProvider()
|
||||
*/
|
||||
public function testStartsWith($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::startsWith($str, $substring, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider endsWithProvider()
|
||||
*/
|
||||
public function testEndsWith($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::endsWith($str, $substring, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toSpacesProvider()
|
||||
*/
|
||||
public function testToSpaces($expected, $str, $tabLength = 4)
|
||||
{
|
||||
$result = S::toSpaces($str, $tabLength);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toTabsProvider()
|
||||
*/
|
||||
public function testToTabs($expected, $str, $tabLength = 4)
|
||||
{
|
||||
$result = S::toTabs($str, $tabLength);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toLowerCaseProvider()
|
||||
*/
|
||||
public function testToLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::toLowerCase($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toTitleCaseProvider()
|
||||
*/
|
||||
public function testToTitleCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::toTitleCase($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toUpperCaseProvider()
|
||||
*/
|
||||
public function testToUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::toUpperCase($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider slugifyProvider()
|
||||
*/
|
||||
public function testSlugify($expected, $str, $replacement = '-')
|
||||
{
|
||||
$result = S::slugify($str, $replacement);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsProvider()
|
||||
*/
|
||||
public function testContains($expected, $haystack, $needle,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::contains($haystack, $needle, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsAnyProvider()
|
||||
*/
|
||||
public function testcontainsAny($expected, $haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::containsAny($haystack, $needles, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsAllProvider()
|
||||
*/
|
||||
public function testContainsAll($expected, $haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::containsAll($haystack, $needles, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider surroundProvider()
|
||||
*/
|
||||
public function testSurround($expected, $str, $substring)
|
||||
{
|
||||
$result = S::surround($str, $substring);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider insertProvider()
|
||||
*/
|
||||
public function testInsert($expected, $str, $substring, $index,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::insert($str, $substring, $index, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider truncateProvider()
|
||||
*/
|
||||
public function testTruncate($expected, $str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::truncate($str, $length, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider safeTruncateProvider()
|
||||
*/
|
||||
public function testSafeTruncate($expected, $str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::safeTruncate($str, $length, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider reverseProvider()
|
||||
*/
|
||||
public function testReverse($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::reverse($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider shuffleProvider()
|
||||
*/
|
||||
public function testShuffle($str, $encoding = null)
|
||||
{
|
||||
$result = S::shuffle($str, $encoding);
|
||||
$encoding = $encoding ?: mb_internal_encoding();
|
||||
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals(mb_strlen($str, $encoding),
|
||||
mb_strlen($result, $encoding));
|
||||
|
||||
// We'll make sure that the chars are present after shuffle
|
||||
for ($i = 0; $i < mb_strlen($str, $encoding); $i++) {
|
||||
$char = mb_substr($str, $i, 1, $encoding);
|
||||
$countBefore = mb_substr_count($str, $char, $encoding);
|
||||
$countAfter = mb_substr_count($result, $char, $encoding);
|
||||
$this->assertEquals($countBefore, $countAfter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider trimProvider()
|
||||
*/
|
||||
public function testTrim($expected, $str)
|
||||
{
|
||||
$result = S::trim($str);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonPrefixProvider()
|
||||
*/
|
||||
public function testLongestCommonPrefix($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::longestCommonPrefix($str, $otherStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonSuffixProvider()
|
||||
*/
|
||||
public function testLongestCommonSuffix($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::longestCommonSuffix($str, $otherStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonSubstringProvider()
|
||||
*/
|
||||
public function testLongestCommonSubstring($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::longestCommonSubstring($str, $otherStr, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lengthProvider()
|
||||
*/
|
||||
public function testLength($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::length($str, $encoding);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertInternalType('int', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider substrProvider()
|
||||
*/
|
||||
public function testSubstr($expected, $str, $start, $length = null,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::substr($str, $start, $length, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider atProvider()
|
||||
*/
|
||||
public function testAt($expected, $str, $index, $encoding = null)
|
||||
{
|
||||
$result = S::at($str, $index, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider firstProvider()
|
||||
*/
|
||||
public function testFirst($expected, $str, $n, $encoding = null)
|
||||
{
|
||||
$result = S::first($str, $n, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lastProvider()
|
||||
*/
|
||||
public function testLast($expected, $str, $n, $encoding = null)
|
||||
{
|
||||
$result = S::last($str, $n, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ensureLeftProvider()
|
||||
*/
|
||||
public function testEnsureLeft($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$result = S::ensureLeft($str, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ensureRightProvider()
|
||||
*/
|
||||
public function testEnsureRight($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$result = S::ensureRight($str, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeLeftProvider()
|
||||
*/
|
||||
public function testRemoveLeft($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$result = S::removeLeft($str, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeRightProvider()
|
||||
*/
|
||||
public function testRemoveRight($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$result = S::removeRight($str, $substring, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isAlphaProvider()
|
||||
*/
|
||||
public function testIsAlpha($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isAlpha($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isAlphanumericProvider()
|
||||
*/
|
||||
public function testIsAlphanumeric($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isAlphanumeric($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isBlankProvider()
|
||||
*/
|
||||
public function testIsBlank($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isBlank($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isJsonProvider()
|
||||
*/
|
||||
public function testIsJson($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isJson($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isLowerCaseProvider()
|
||||
*/
|
||||
public function testIsLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isLowerCase($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasLowerCaseProvider()
|
||||
*/
|
||||
public function testHasLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::hasLowerCase($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isSerializedProvider()
|
||||
*/
|
||||
public function testIsSerialized($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isSerialized($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isUpperCaseProvider()
|
||||
*/
|
||||
public function testIsUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isUpperCase($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasUpperCaseProvider()
|
||||
*/
|
||||
public function testHasUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::hasUpperCase($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isHexadecimalProvider()
|
||||
*/
|
||||
public function testIsHexadecimal($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::isHexadecimal($str, $encoding);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider countSubstrProvider()
|
||||
*/
|
||||
public function testCountSubstr($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$result = S::countSubstr($str, $substring, $caseSensitive, $encoding);
|
||||
$this->assertInternalType('int', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider replaceProvider()
|
||||
*/
|
||||
public function testReplace($expected, $str, $search, $replacement,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::replace($str, $search, $replacement, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider regexReplaceProvider()
|
||||
*/
|
||||
public function testRegexReplace($expected, $str, $pattern, $replacement,
|
||||
$options = 'msr', $encoding = null)
|
||||
{
|
||||
$result = S::regexReplace($str, $pattern, $replacement, $options, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
914
vendor/danielstjules/stringy/tests/StringyTest.php
vendored
Executable file
914
vendor/danielstjules/stringy/tests/StringyTest.php
vendored
Executable file
@ -0,0 +1,914 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/Stringy.php';
|
||||
|
||||
use Stringy\Stringy as S;
|
||||
|
||||
class StringyTestCase extends CommonTest
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$stringy = new S('foo bar', 'UTF-8');
|
||||
$this->assertStringy($stringy);
|
||||
$this->assertEquals('foo bar', (string) $stringy);
|
||||
$this->assertEquals('UTF-8', $stringy->getEncoding());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testConstructWithArray()
|
||||
{
|
||||
(string) new S(array());
|
||||
$this->fail('Expecting exception when the constructor is passed an array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testMissingToString()
|
||||
{
|
||||
(string) new S(new stdClass());
|
||||
$this->fail('Expecting exception when the constructor is passed an ' .
|
||||
'object without a __toString method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toStringProvider()
|
||||
*/
|
||||
public function testToString($expected, $str)
|
||||
{
|
||||
$this->assertEquals($expected, (string) new S($str));
|
||||
}
|
||||
|
||||
public function toStringProvider()
|
||||
{
|
||||
return array(
|
||||
array('', null),
|
||||
array('', false),
|
||||
array('1', true),
|
||||
array('-9', -9),
|
||||
array('1.18', 1.18),
|
||||
array(' string ', ' string ')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$stringy = S::create('foo bar', 'UTF-8');
|
||||
$this->assertStringy($stringy);
|
||||
$this->assertEquals('foo bar', (string) $stringy);
|
||||
$this->assertEquals('UTF-8', $stringy->getEncoding());
|
||||
}
|
||||
|
||||
public function testChaining()
|
||||
{
|
||||
$stringy = S::create("Fòô Bàř", 'UTF-8');
|
||||
$this->assertStringy($stringy);
|
||||
$result = $stringy->collapseWhitespace()->swapCase()->upperCaseFirst();
|
||||
$this->assertEquals('FÒÔ bÀŘ', $result);
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
{
|
||||
$stringy = S::create('Fòô', 'UTF-8');
|
||||
$this->assertEquals(3, $stringy->count());
|
||||
$this->assertEquals(3, count($stringy));
|
||||
}
|
||||
|
||||
public function testGetIterator()
|
||||
{
|
||||
$stringy = S::create('Fòô Bàř', 'UTF-8');
|
||||
|
||||
$valResult = array();
|
||||
foreach ($stringy as $char) {
|
||||
$valResult[] = $char;
|
||||
}
|
||||
|
||||
$keyValResult = array();
|
||||
foreach ($stringy as $pos => $char) {
|
||||
$keyValResult[$pos] = $char;
|
||||
}
|
||||
|
||||
$this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $valResult);
|
||||
$this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $keyValResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider offsetExistsProvider()
|
||||
*/
|
||||
public function testOffsetExists($expected, $offset)
|
||||
{
|
||||
$stringy = S::create('fòô', 'UTF-8');
|
||||
$this->assertEquals($expected, $stringy->offsetExists($offset));
|
||||
$this->assertEquals($expected, isset($stringy[$offset]));
|
||||
}
|
||||
|
||||
public function offsetExistsProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, 0),
|
||||
array(true, 2),
|
||||
array(false, 3),
|
||||
array(true, -1),
|
||||
array(true, -3),
|
||||
array(false, -4)
|
||||
);
|
||||
}
|
||||
|
||||
public function testOffsetGet()
|
||||
{
|
||||
$stringy = S::create('fòô', 'UTF-8');
|
||||
|
||||
$this->assertEquals('f', $stringy->offsetGet(0));
|
||||
$this->assertEquals('ô', $stringy->offsetGet(2));
|
||||
|
||||
$this->assertEquals('ô', $stringy[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testOffsetGetOutOfBounds()
|
||||
{
|
||||
$stringy = S::create('fòô', 'UTF-8');
|
||||
$test = $stringy[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testOffsetSet()
|
||||
{
|
||||
$stringy = S::create('fòô', 'UTF-8');
|
||||
$stringy[1] = 'invalid';
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testOffsetUnset()
|
||||
{
|
||||
$stringy = S::create('fòô', 'UTF-8');
|
||||
unset($stringy[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider charsProvider()
|
||||
*/
|
||||
public function testChars($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::create($str, $encoding)->chars();
|
||||
$this->assertInternalType('array', $result);
|
||||
foreach ($result as $char) {
|
||||
$this->assertInternalType('string', $char);
|
||||
}
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upperCaseFirstProvider()
|
||||
*/
|
||||
public function testUpperCaseFirst($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::create($str, $encoding)->upperCaseFirst();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lowerCaseFirstProvider()
|
||||
*/
|
||||
public function testLowerCaseFirst($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->lowerCaseFirst();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider camelizeProvider()
|
||||
*/
|
||||
public function testCamelize($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->camelize();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upperCamelizeProvider()
|
||||
*/
|
||||
public function testUpperCamelize($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->upperCamelize();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dasherizeProvider()
|
||||
*/
|
||||
public function testDasherize($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->dasherize();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider underscoredProvider()
|
||||
*/
|
||||
public function testUnderscored($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->underscored();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider swapCaseProvider()
|
||||
*/
|
||||
public function testSwapCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->swapCase();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider titleizeProvider()
|
||||
*/
|
||||
public function testTitleize($expected, $str, $ignore = null,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->titleize($ignore);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider humanizeProvider()
|
||||
*/
|
||||
public function testHumanize($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->humanize();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider tidyProvider()
|
||||
*/
|
||||
public function testTidy($expected, $str)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->tidy();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider collapseWhitespaceProvider()
|
||||
*/
|
||||
public function testCollapseWhitespace($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->collapseWhitespace();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toAsciiProvider()
|
||||
*/
|
||||
public function testToAscii($expected, $str, $removeUnsupported = true)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->toAscii($removeUnsupported);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padProvider()
|
||||
*/
|
||||
public function testPad($expected, $str, $length, $padStr = ' ',
|
||||
$padType = 'right', $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->pad($length, $padStr, $padType);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testPadException()
|
||||
{
|
||||
$stringy = S::create('foo');
|
||||
$result = $stringy->pad(5, 'foo', 'bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padLeftProvider()
|
||||
*/
|
||||
public function testPadLeft($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->padLeft($length, $padStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padRightProvider()
|
||||
*/
|
||||
public function testPadRight($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->padRight($length, $padStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider padBothProvider()
|
||||
*/
|
||||
public function testPadBoth($expected, $str, $length, $padStr = ' ',
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->padBoth($length, $padStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider startsWithProvider()
|
||||
*/
|
||||
public function testStartsWith($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->startsWith($substring, $caseSensitive);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider endsWithProvider()
|
||||
*/
|
||||
public function testEndsWith($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->endsWith($substring, $caseSensitive);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toSpacesProvider()
|
||||
*/
|
||||
public function testToSpaces($expected, $str, $tabLength = 4)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->toSpaces($tabLength);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toTabsProvider()
|
||||
*/
|
||||
public function testToTabs($expected, $str, $tabLength = 4)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->toTabs($tabLength);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toLowerCaseProvider()
|
||||
*/
|
||||
public function testToLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->toLowerCase();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toTitleCaseProvider()
|
||||
*/
|
||||
public function testToTitleCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->toTitleCase();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider toUpperCaseProvider()
|
||||
*/
|
||||
public function testToUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->toUpperCase();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider slugifyProvider()
|
||||
*/
|
||||
public function testSlugify($expected, $str, $replacement = '-')
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->slugify($replacement);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsProvider()
|
||||
*/
|
||||
public function testContains($expected, $haystack, $needle,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($haystack, $encoding);
|
||||
$result = $stringy->contains($needle, $caseSensitive);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($haystack, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsAnyProvider()
|
||||
*/
|
||||
public function testcontainsAny($expected, $haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($haystack, $encoding);
|
||||
$result = $stringy->containsAny($needles, $caseSensitive);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($haystack, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsAllProvider()
|
||||
*/
|
||||
public function testContainsAll($expected, $haystack, $needles,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($haystack, $encoding);
|
||||
$result = $stringy->containsAll($needles, $caseSensitive);
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($haystack, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider surroundProvider()
|
||||
*/
|
||||
public function testSurround($expected, $str, $substring)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->surround($substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider insertProvider()
|
||||
*/
|
||||
public function testInsert($expected, $str, $substring, $index,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->insert($substring, $index);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider truncateProvider()
|
||||
*/
|
||||
public function testTruncate($expected, $str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->truncate($length, $substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider safeTruncateProvider()
|
||||
*/
|
||||
public function testSafeTruncate($expected, $str, $length, $substring = '',
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->safeTruncate($length, $substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider reverseProvider()
|
||||
*/
|
||||
public function testReverse($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->reverse();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider shuffleProvider()
|
||||
*/
|
||||
public function testShuffle($str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$encoding = $encoding ?: mb_internal_encoding();
|
||||
$result = $stringy->shuffle();
|
||||
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
$this->assertEquals(mb_strlen($str, $encoding),
|
||||
mb_strlen($result, $encoding));
|
||||
|
||||
// We'll make sure that the chars are present after shuffle
|
||||
for ($i = 0; $i < mb_strlen($str, $encoding); $i++) {
|
||||
$char = mb_substr($str, $i, 1, $encoding);
|
||||
$countBefore = mb_substr_count($str, $char, $encoding);
|
||||
$countAfter = mb_substr_count($result, $char, $encoding);
|
||||
$this->assertEquals($countBefore, $countAfter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider trimProvider()
|
||||
*/
|
||||
public function testTrim($expected, $str)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$result = $stringy->trim();
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonPrefixProvider()
|
||||
*/
|
||||
public function testLongestCommonPrefix($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->longestCommonPrefix($otherStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonSuffixProvider()
|
||||
*/
|
||||
public function testLongestCommonSuffix($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->longestCommonSuffix($otherStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider longestCommonSubstringProvider()
|
||||
*/
|
||||
public function testLongestCommonSubstring($expected, $str, $otherStr,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->longestCommonSubstring($otherStr);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lengthProvider()
|
||||
*/
|
||||
public function testLength($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->length();
|
||||
$this->assertInternalType('int', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider substrProvider()
|
||||
*/
|
||||
public function testSubstr($expected, $str, $start, $length = null,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->substr($start, $length);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider atProvider()
|
||||
*/
|
||||
public function testAt($expected, $str, $index, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->at($index);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider firstProvider()
|
||||
*/
|
||||
public function testFirst($expected, $str, $n, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->first($n);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider lastProvider()
|
||||
*/
|
||||
public function testLast($expected, $str, $n, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->last($n);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ensureLeftProvider()
|
||||
*/
|
||||
public function testEnsureLeft($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->ensureLeft($substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ensureRightProvider()
|
||||
*/
|
||||
public function testEnsureRight($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->ensureRight($substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeLeftProvider()
|
||||
*/
|
||||
public function testRemoveLeft($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->removeLeft($substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider removeRightProvider()
|
||||
*/
|
||||
public function testRemoveRight($expected, $str, $substring, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->removeRight($substring);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isAlphaProvider()
|
||||
*/
|
||||
public function testIsAlpha($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isAlpha();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isAlphanumericProvider()
|
||||
*/
|
||||
public function testIsAlphanumeric($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isAlphanumeric();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isBlankProvider()
|
||||
*/
|
||||
public function testIsBlank($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isBlank();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isJsonProvider()
|
||||
*/
|
||||
public function testIsJson($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isJson();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isLowerCaseProvider()
|
||||
*/
|
||||
public function testIsLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isLowerCase();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasLowerCaseProvider()
|
||||
*/
|
||||
public function testHasLowerCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->hasLowerCase();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isSerializedProvider()
|
||||
*/
|
||||
public function testIsSerialized($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isSerialized();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isUpperCaseProvider()
|
||||
*/
|
||||
public function testIsUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isUpperCase();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider hasUpperCaseProvider()
|
||||
*/
|
||||
public function testHasUpperCase($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->hasUpperCase();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isHexadecimalProvider()
|
||||
*/
|
||||
public function testIsHexadecimal($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->isHexadecimal();
|
||||
$this->assertInternalType('boolean', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider countSubstrProvider()
|
||||
*/
|
||||
public function testCountSubstr($expected, $str, $substring,
|
||||
$caseSensitive = true, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->countSubstr($substring, $caseSensitive);
|
||||
$this->assertInternalType('int', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider replaceProvider()
|
||||
*/
|
||||
public function testReplace($expected, $str, $search, $replacement,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->replace($search, $replacement);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider regexReplaceProvider()
|
||||
*/
|
||||
public function testregexReplace($expected, $str, $pattern, $replacement,
|
||||
$options = 'msr', $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->regexReplace($pattern, $replacement, $options);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
}
|
19
vendor/doctrine/inflector/LICENSE
vendored
Executable file
19
vendor/doctrine/inflector/LICENSE
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2013 Doctrine Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
6
vendor/doctrine/inflector/README.md
vendored
Executable file
6
vendor/doctrine/inflector/README.md
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
# Doctrine Inflector
|
||||
|
||||
Doctrine Inflector is a small library that can perform string manipulations
|
||||
with regard to upper-/lowercase and singular/plural forms of words.
|
||||
|
||||
[![Build Status](https://travis-ci.org/doctrine/inflector.svg?branch=master)](https://travis-ci.org/doctrine/inflector)
|
29
vendor/doctrine/inflector/composer.json
vendored
Executable file
29
vendor/doctrine/inflector/composer.json
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"type": "library",
|
||||
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
|
||||
"keywords": ["string", "inflection", "singularize", "pluralize"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Doctrine\\Common\\Inflector\\": "lib/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
415
vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php
vendored
Executable file
415
vendor/doctrine/inflector/lib/Doctrine/Common/Inflector/Inflector.php
vendored
Executable file
@ -0,0 +1,415 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Inflector;
|
||||
|
||||
/**
|
||||
* Doctrine inflector has static methods for inflecting text.
|
||||
*
|
||||
* The methods in these classes are from several different sources collected
|
||||
* across several different php projects and several different authors. The
|
||||
* original author names and emails are not known.
|
||||
*
|
||||
* Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.0
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class Inflector
|
||||
{
|
||||
/**
|
||||
* Plural inflector rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $plural = array(
|
||||
'rules' => array(
|
||||
'/(s)tatus$/i' => '\1\2tatuses',
|
||||
'/(quiz)$/i' => '\1zes',
|
||||
'/^(ox)$/i' => '\1\2en',
|
||||
'/([m|l])ouse$/i' => '\1ice',
|
||||
'/(matr|vert|ind)(ix|ex)$/i' => '\1ices',
|
||||
'/(x|ch|ss|sh)$/i' => '\1es',
|
||||
'/([^aeiouy]|qu)y$/i' => '\1ies',
|
||||
'/(hive)$/i' => '\1s',
|
||||
'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
|
||||
'/sis$/i' => 'ses',
|
||||
'/([ti])um$/i' => '\1a',
|
||||
'/(p)erson$/i' => '\1eople',
|
||||
'/(m)an$/i' => '\1en',
|
||||
'/(c)hild$/i' => '\1hildren',
|
||||
'/(buffal|tomat)o$/i' => '\1\2oes',
|
||||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
|
||||
'/us$/i' => 'uses',
|
||||
'/(alias)$/i' => '\1es',
|
||||
'/(ax|cris|test)is$/i' => '\1es',
|
||||
'/s$/' => 's',
|
||||
'/^$/' => '',
|
||||
'/$/' => 's',
|
||||
),
|
||||
'uninflected' => array(
|
||||
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie'
|
||||
),
|
||||
'irregular' => array(
|
||||
'atlas' => 'atlases',
|
||||
'beef' => 'beefs',
|
||||
'brother' => 'brothers',
|
||||
'cafe' => 'cafes',
|
||||
'child' => 'children',
|
||||
'cookie' => 'cookies',
|
||||
'corpus' => 'corpuses',
|
||||
'cow' => 'cows',
|
||||
'criteria' => 'criterion',
|
||||
'ganglion' => 'ganglions',
|
||||
'genie' => 'genies',
|
||||
'genus' => 'genera',
|
||||
'graffito' => 'graffiti',
|
||||
'hoof' => 'hoofs',
|
||||
'human' => 'humans',
|
||||
'loaf' => 'loaves',
|
||||
'man' => 'men',
|
||||
'money' => 'monies',
|
||||
'mongoose' => 'mongooses',
|
||||
'move' => 'moves',
|
||||
'mythos' => 'mythoi',
|
||||
'niche' => 'niches',
|
||||
'numen' => 'numina',
|
||||
'occiput' => 'occiputs',
|
||||
'octopus' => 'octopuses',
|
||||
'opus' => 'opuses',
|
||||
'ox' => 'oxen',
|
||||
'penis' => 'penises',
|
||||
'person' => 'people',
|
||||
'sex' => 'sexes',
|
||||
'soliloquy' => 'soliloquies',
|
||||
'testis' => 'testes',
|
||||
'trilby' => 'trilbys',
|
||||
'turf' => 'turfs',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Singular inflector rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $singular = array(
|
||||
'rules' => array(
|
||||
'/(s)tatuses$/i' => '\1\2tatus',
|
||||
'/^(.*)(menu)s$/i' => '\1\2',
|
||||
'/(quiz)zes$/i' => '\\1',
|
||||
'/(matr)ices$/i' => '\1ix',
|
||||
'/(vert|ind)ices$/i' => '\1ex',
|
||||
'/^(ox)en/i' => '\1',
|
||||
'/(alias)(es)*$/i' => '\1',
|
||||
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
|
||||
'/([ftw]ax)es/i' => '\1',
|
||||
'/(cris|ax|test)es$/i' => '\1is',
|
||||
'/(shoe|slave)s$/i' => '\1',
|
||||
'/(o)es$/i' => '\1',
|
||||
'/ouses$/' => 'ouse',
|
||||
'/([^a])uses$/' => '\1us',
|
||||
'/([m|l])ice$/i' => '\1ouse',
|
||||
'/(x|ch|ss|sh)es$/i' => '\1',
|
||||
'/(m)ovies$/i' => '\1\2ovie',
|
||||
'/(s)eries$/i' => '\1\2eries',
|
||||
'/([^aeiouy]|qu)ies$/i' => '\1y',
|
||||
'/([lr])ves$/i' => '\1f',
|
||||
'/(tive)s$/i' => '\1',
|
||||
'/(hive)s$/i' => '\1',
|
||||
'/(drive)s$/i' => '\1',
|
||||
'/([^fo])ves$/i' => '\1fe',
|
||||
'/(^analy)ses$/i' => '\1sis',
|
||||
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
||||
'/([ti])a$/i' => '\1um',
|
||||
'/(p)eople$/i' => '\1\2erson',
|
||||
'/(m)en$/i' => '\1an',
|
||||
'/(c)hildren$/i' => '\1\2hild',
|
||||
'/(n)ews$/i' => '\1\2ews',
|
||||
'/eaus$/' => 'eau',
|
||||
'/^(.*us)$/' => '\\1',
|
||||
'/s$/i' => '',
|
||||
),
|
||||
'uninflected' => array(
|
||||
'.*[nrlm]ese',
|
||||
'.*deer',
|
||||
'.*fish',
|
||||
'.*measles',
|
||||
'.*ois',
|
||||
'.*pox',
|
||||
'.*sheep',
|
||||
'.*ss',
|
||||
),
|
||||
'irregular' => array(
|
||||
'criterion' => 'criteria',
|
||||
'curves' => 'curve',
|
||||
'foes' => 'foe',
|
||||
'waves' => 'wave',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Words that should not be inflected.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $uninflected = array(
|
||||
'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus',
|
||||
'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps',
|
||||
'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder',
|
||||
'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti',
|
||||
'headquarters', 'herpes', 'hijinks', 'Hottentotese', 'information', 'innings',
|
||||
'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', '.*?media',
|
||||
'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese',
|
||||
'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese',
|
||||
'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors',
|
||||
'sea[- ]bass', 'series', 'Shavese', 'shears', 'siemens', 'species', 'staff', 'swine',
|
||||
'testes', 'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting',
|
||||
'wildebeest', 'Yengeese'
|
||||
);
|
||||
|
||||
/**
|
||||
* Method cache array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $cache = array();
|
||||
|
||||
/**
|
||||
* The initial state of Inflector so reset() works.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $initialState = array();
|
||||
|
||||
/**
|
||||
* Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.
|
||||
*
|
||||
* @param string $word The word to tableize.
|
||||
*
|
||||
* @return string The tableized word.
|
||||
*/
|
||||
public static function tableize($word)
|
||||
{
|
||||
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'.
|
||||
*
|
||||
* @param string $word The word to classify.
|
||||
*
|
||||
* @return string The classified word.
|
||||
*/
|
||||
public static function classify($word)
|
||||
{
|
||||
return str_replace(" ", "", ucwords(strtr($word, "_-", " ")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Camelizes a word. This uses the classify() method and turns the first character to lowercase.
|
||||
*
|
||||
* @param string $word The word to camelize.
|
||||
*
|
||||
* @return string The camelized word.
|
||||
*/
|
||||
public static function camelize($word)
|
||||
{
|
||||
return lcfirst(self::classify($word));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears Inflectors inflected value caches, and resets the inflection
|
||||
* rules to the initial values.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function reset()
|
||||
{
|
||||
if (empty(self::$initialState)) {
|
||||
self::$initialState = get_class_vars('Inflector');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (self::$initialState as $key => $val) {
|
||||
if ($key != 'initialState') {
|
||||
self::${$key} = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom inflection $rules, of either 'plural' or 'singular' $type.
|
||||
*
|
||||
* ### Usage:
|
||||
*
|
||||
* {{{
|
||||
* Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables'));
|
||||
* Inflector::rules('plural', array(
|
||||
* 'rules' => array('/^(inflect)ors$/i' => '\1ables'),
|
||||
* 'uninflected' => array('dontinflectme'),
|
||||
* 'irregular' => array('red' => 'redlings')
|
||||
* ));
|
||||
* }}}
|
||||
*
|
||||
* @param string $type The type of inflection, either 'plural' or 'singular'
|
||||
* @param array $rules An array of rules to be added.
|
||||
* @param boolean $reset If true, will unset default inflections for all
|
||||
* new rules that are being defined in $rules.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function rules($type, $rules, $reset = false)
|
||||
{
|
||||
foreach ($rules as $rule => $pattern) {
|
||||
if ( ! is_array($pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($reset) {
|
||||
self::${$type}[$rule] = $pattern;
|
||||
} else {
|
||||
self::${$type}[$rule] = ($rule === 'uninflected')
|
||||
? array_merge($pattern, self::${$type}[$rule])
|
||||
: $pattern + self::${$type}[$rule];
|
||||
}
|
||||
|
||||
unset($rules[$rule], self::${$type}['cache' . ucfirst($rule)]);
|
||||
|
||||
if (isset(self::${$type}['merged'][$rule])) {
|
||||
unset(self::${$type}['merged'][$rule]);
|
||||
}
|
||||
|
||||
if ($type === 'plural') {
|
||||
self::$cache['pluralize'] = self::$cache['tableize'] = array();
|
||||
} elseif ($type === 'singular') {
|
||||
self::$cache['singularize'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
self::${$type}['rules'] = $rules + self::${$type}['rules'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a word in plural form.
|
||||
*
|
||||
* @param string $word The word in singular form.
|
||||
*
|
||||
* @return string The word in plural form.
|
||||
*/
|
||||
public static function pluralize($word)
|
||||
{
|
||||
if (isset(self::$cache['pluralize'][$word])) {
|
||||
return self::$cache['pluralize'][$word];
|
||||
}
|
||||
|
||||
if (!isset(self::$plural['merged']['irregular'])) {
|
||||
self::$plural['merged']['irregular'] = self::$plural['irregular'];
|
||||
}
|
||||
|
||||
if (!isset(self::$plural['merged']['uninflected'])) {
|
||||
self::$plural['merged']['uninflected'] = array_merge(self::$plural['uninflected'], self::$uninflected);
|
||||
}
|
||||
|
||||
if (!isset(self::$plural['cacheUninflected']) || !isset(self::$plural['cacheIrregular'])) {
|
||||
self::$plural['cacheUninflected'] = '(?:' . implode('|', self::$plural['merged']['uninflected']) . ')';
|
||||
self::$plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$plural['merged']['irregular'])) . ')';
|
||||
}
|
||||
|
||||
if (preg_match('/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs)) {
|
||||
self::$cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$plural['merged']['irregular'][strtolower($regs[2])], 1);
|
||||
|
||||
return self::$cache['pluralize'][$word];
|
||||
}
|
||||
|
||||
if (preg_match('/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs)) {
|
||||
self::$cache['pluralize'][$word] = $word;
|
||||
|
||||
return $word;
|
||||
}
|
||||
|
||||
foreach (self::$plural['rules'] as $rule => $replacement) {
|
||||
if (preg_match($rule, $word)) {
|
||||
self::$cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
|
||||
|
||||
return self::$cache['pluralize'][$word];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a word in singular form.
|
||||
*
|
||||
* @param string $word The word in plural form.
|
||||
*
|
||||
* @return string The word in singular form.
|
||||
*/
|
||||
public static function singularize($word)
|
||||
{
|
||||
if (isset(self::$cache['singularize'][$word])) {
|
||||
return self::$cache['singularize'][$word];
|
||||
}
|
||||
|
||||
if (!isset(self::$singular['merged']['uninflected'])) {
|
||||
self::$singular['merged']['uninflected'] = array_merge(
|
||||
self::$singular['uninflected'],
|
||||
self::$uninflected
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset(self::$singular['merged']['irregular'])) {
|
||||
self::$singular['merged']['irregular'] = array_merge(
|
||||
self::$singular['irregular'],
|
||||
array_flip(self::$plural['irregular'])
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset(self::$singular['cacheUninflected']) || !isset(self::$singular['cacheIrregular'])) {
|
||||
self::$singular['cacheUninflected'] = '(?:' . join('|', self::$singular['merged']['uninflected']) . ')';
|
||||
self::$singular['cacheIrregular'] = '(?:' . join('|', array_keys(self::$singular['merged']['irregular'])) . ')';
|
||||
}
|
||||
|
||||
if (preg_match('/(.*)\\b(' . self::$singular['cacheIrregular'] . ')$/i', $word, $regs)) {
|
||||
self::$cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$singular['merged']['irregular'][strtolower($regs[2])], 1);
|
||||
|
||||
return self::$cache['singularize'][$word];
|
||||
}
|
||||
|
||||
if (preg_match('/^(' . self::$singular['cacheUninflected'] . ')$/i', $word, $regs)) {
|
||||
self::$cache['singularize'][$word] = $word;
|
||||
|
||||
return $word;
|
||||
}
|
||||
|
||||
foreach (self::$singular['rules'] as $rule => $replacement) {
|
||||
if (preg_match($rule, $word)) {
|
||||
self::$cache['singularize'][$word] = preg_replace($rule, $replacement, $word);
|
||||
|
||||
return self::$cache['singularize'][$word];
|
||||
}
|
||||
}
|
||||
|
||||
self::$cache['singularize'][$word] = $word;
|
||||
|
||||
return $word;
|
||||
}
|
||||
}
|
31
vendor/doctrine/inflector/phpunit.xml.dist
vendored
Executable file
31
vendor/doctrine/inflector/phpunit.xml.dist
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./tests/Doctrine/Tests/TestInit.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Doctrine Inflector Test Suite">
|
||||
<directory>./tests/Doctrine/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./lib/Doctrine/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>performance</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
</phpunit>
|
210
vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php
vendored
Executable file
210
vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php
vendored
Executable file
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Inflector;
|
||||
|
||||
use Doctrine\Tests\DoctrineTestCase;
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
|
||||
class InflectorTest extends DoctrineTestCase
|
||||
{
|
||||
/**
|
||||
* Singular & Plural test data. Returns an array of sample words.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function dataSampleWords()
|
||||
{
|
||||
Inflector::reset();
|
||||
|
||||
// in the format array('singular', 'plural')
|
||||
return array(
|
||||
array('categoria', 'categorias'),
|
||||
array('house', 'houses'),
|
||||
array('powerhouse', 'powerhouses'),
|
||||
array('Bus', 'Buses'),
|
||||
array('bus', 'buses'),
|
||||
array('menu', 'menus'),
|
||||
array('news', 'news'),
|
||||
array('food_menu', 'food_menus'),
|
||||
array('Menu', 'Menus'),
|
||||
array('FoodMenu', 'FoodMenus'),
|
||||
array('quiz', 'quizzes'),
|
||||
array('matrix_row', 'matrix_rows'),
|
||||
array('matrix', 'matrices'),
|
||||
array('vertex', 'vertices'),
|
||||
array('index', 'indices'),
|
||||
array('Alias', 'Aliases'),
|
||||
array('Media', 'Media'),
|
||||
array('NodeMedia', 'NodeMedia'),
|
||||
array('alumnus', 'alumni'),
|
||||
array('bacillus', 'bacilli'),
|
||||
array('cactus', 'cacti'),
|
||||
array('focus', 'foci'),
|
||||
array('fungus', 'fungi'),
|
||||
array('nucleus', 'nuclei'),
|
||||
array('octopus', 'octopuses'),
|
||||
array('radius', 'radii'),
|
||||
array('stimulus', 'stimuli'),
|
||||
array('syllabus', 'syllabi'),
|
||||
array('terminus', 'termini'),
|
||||
array('virus', 'viri'),
|
||||
array('person', 'people'),
|
||||
array('glove', 'gloves'),
|
||||
array('crisis', 'crises'),
|
||||
array('tax', 'taxes'),
|
||||
array('wave', 'waves'),
|
||||
array('bureau', 'bureaus'),
|
||||
array('cafe', 'cafes'),
|
||||
array('roof', 'roofs'),
|
||||
array('foe', 'foes'),
|
||||
array('cookie', 'cookies'),
|
||||
array('identity', 'identities'),
|
||||
array('criteria', 'criterion'),
|
||||
array('curve', 'curves'),
|
||||
array('', ''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* testInflectingSingulars method
|
||||
*
|
||||
* @dataProvider dataSampleWords
|
||||
* @return void
|
||||
*/
|
||||
public function testInflectingSingulars($singular, $plural)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$singular,
|
||||
Inflector::singularize($plural),
|
||||
"'$plural' should be singularized to '$singular'"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* testInflectingPlurals method
|
||||
*
|
||||
* @dataProvider dataSampleWords
|
||||
* @return void
|
||||
*/
|
||||
public function testInflectingPlurals($singular, $plural)
|
||||
{
|
||||
$this->assertEquals(
|
||||
$plural,
|
||||
Inflector::pluralize($singular),
|
||||
"'$singular' should be pluralized to '$plural'"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* testCustomPluralRule method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomPluralRule()
|
||||
{
|
||||
Inflector::reset();
|
||||
Inflector::rules('plural', array('/^(custom)$/i' => '\1izables'));
|
||||
|
||||
$this->assertEquals(Inflector::pluralize('custom'), 'customizables');
|
||||
|
||||
Inflector::rules('plural', array('uninflected' => array('uninflectable')));
|
||||
|
||||
$this->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable');
|
||||
|
||||
Inflector::rules('plural', array(
|
||||
'rules' => array('/^(alert)$/i' => '\1ables'),
|
||||
'uninflected' => array('noflect', 'abtuse'),
|
||||
'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes')
|
||||
));
|
||||
|
||||
$this->assertEquals(Inflector::pluralize('noflect'), 'noflect');
|
||||
$this->assertEquals(Inflector::pluralize('abtuse'), 'abtuse');
|
||||
$this->assertEquals(Inflector::pluralize('alert'), 'alertables');
|
||||
$this->assertEquals(Inflector::pluralize('amaze'), 'amazable');
|
||||
$this->assertEquals(Inflector::pluralize('phone'), 'phonezes');
|
||||
}
|
||||
|
||||
/**
|
||||
* testCustomSingularRule method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomSingularRule()
|
||||
{
|
||||
Inflector::reset();
|
||||
Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1'));
|
||||
|
||||
$this->assertEquals(Inflector::singularize('epler'), 'eple');
|
||||
$this->assertEquals(Inflector::singularize('jenter'), 'jente');
|
||||
|
||||
Inflector::rules('singular', array(
|
||||
'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),
|
||||
'uninflected' => array('singulars'),
|
||||
'irregular' => array('spins' => 'spinor')
|
||||
));
|
||||
|
||||
$this->assertEquals(Inflector::singularize('inflectors'), 'inflecta');
|
||||
$this->assertEquals(Inflector::singularize('contributors'), 'contributa');
|
||||
$this->assertEquals(Inflector::singularize('spins'), 'spinor');
|
||||
$this->assertEquals(Inflector::singularize('singulars'), 'singulars');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that setting new rules clears the inflector caches.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRulesClearsCaches()
|
||||
{
|
||||
Inflector::reset();
|
||||
|
||||
$this->assertEquals(Inflector::singularize('Bananas'), 'Banana');
|
||||
$this->assertEquals(Inflector::pluralize('Banana'), 'Bananas');
|
||||
|
||||
Inflector::rules('singular', array(
|
||||
'rules' => array('/(.*)nas$/i' => '\1zzz')
|
||||
));
|
||||
|
||||
$this->assertEquals('Banazzz', Inflector::singularize('Bananas'), 'Was inflected with old rules.');
|
||||
|
||||
Inflector::rules('plural', array(
|
||||
'rules' => array('/(.*)na$/i' => '\1zzz'),
|
||||
'irregular' => array('corpus' => 'corpora')
|
||||
));
|
||||
|
||||
$this->assertEquals(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules.');
|
||||
$this->assertEquals(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test resetting inflection rules.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomRuleWithReset()
|
||||
{
|
||||
Inflector::reset();
|
||||
|
||||
$uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
|
||||
$pluralIrregular = array('as' => 'ases');
|
||||
|
||||
Inflector::rules('singular', array(
|
||||
'rules' => array('/^(.*)(a|e|o|u)is$/i' => '\1\2l'),
|
||||
'uninflected' => $uninflected,
|
||||
), true);
|
||||
|
||||
Inflector::rules('plural', array(
|
||||
'rules' => array(
|
||||
'/^(.*)(a|e|o|u)l$/i' => '\1\2is',
|
||||
),
|
||||
'uninflected' => $uninflected,
|
||||
'irregular' => $pluralIrregular
|
||||
), true);
|
||||
|
||||
$this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois');
|
||||
$this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas');
|
||||
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
|
||||
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
|
||||
}
|
||||
}
|
||||
|
10
vendor/doctrine/inflector/tests/Doctrine/Tests/DoctrineTestCase.php
vendored
Executable file
10
vendor/doctrine/inflector/tests/Doctrine/Tests/DoctrineTestCase.php
vendored
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests;
|
||||
|
||||
/**
|
||||
* Base testcase class for all Doctrine testcases.
|
||||
*/
|
||||
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
27
vendor/doctrine/inflector/tests/Doctrine/Tests/TestInit.php
vendored
Executable file
27
vendor/doctrine/inflector/tests/Doctrine/Tests/TestInit.php
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
* This file bootstraps the test environment.
|
||||
*/
|
||||
namespace Doctrine\Tests;
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
// register silently failing autoloader
|
||||
spl_autoload_register(function($class)
|
||||
{
|
||||
if (0 === strpos($class, 'Doctrine\Tests\\')) {
|
||||
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
|
||||
if (is_file($path) && is_readable($path)) {
|
||||
require_once $path;
|
||||
|
||||
return true;
|
||||
}
|
||||
} else if (0 === strpos($class, 'Doctrine\Common\\')) {
|
||||
$path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
|
||||
if (is_file($path) && is_readable($path)) {
|
||||
require_once $path;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
99
vendor/hassankhan/config/CHANGELOG.md
vendored
Executable file
99
vendor/hassankhan/config/CHANGELOG.md
vendored
Executable file
@ -0,0 +1,99 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `Config` will be documented in this file
|
||||
|
||||
## 0.8.2 - 2015-03-21
|
||||
|
||||
### Fixed
|
||||
- Some code smells in `Config`
|
||||
- Updated README.md
|
||||
|
||||
|
||||
## 0.8.1 - 2015-03-21
|
||||
|
||||
### Fixed
|
||||
- Various things relating to recent repo transfer
|
||||
|
||||
|
||||
## 0.8.0 - 2015-03-21
|
||||
|
||||
### Added
|
||||
- Individual `FileParser` classes for each filetype, and a `FileParserInterface` to type-hint methods with
|
||||
- Optional paths; you can now prefix a path with '?' and `Config` will skip the file if it doesn't exist
|
||||
|
||||
### Fixed
|
||||
- Made the Symfony YAML component a suggested dependency
|
||||
- Parent constructor was not being called from `Config`
|
||||
|
||||
|
||||
## 0.7.1 - 2015-02-24
|
||||
|
||||
### Added
|
||||
- Moved file logic into file-specific loaders
|
||||
|
||||
### Fixed
|
||||
- Corrected class name in README.md
|
||||
|
||||
|
||||
## 0.7.0 - 2015-02-23
|
||||
|
||||
### Fixed
|
||||
- Removed kludgy hack for YAML/YML
|
||||
|
||||
|
||||
## 0.6.0 - 2015-02-23
|
||||
|
||||
### Added
|
||||
- Can now extend `AbstractConfig` to create simple subclasses without any file IO
|
||||
|
||||
|
||||
## 0.5.0 - 2015-02-23
|
||||
|
||||
### Added
|
||||
- Moved file logic into file-specific loaders
|
||||
|
||||
### Fixed
|
||||
- Cleaned up exception class constructors, PSR-2 compliance
|
||||
|
||||
|
||||
## 0.4.0 - 2015-02-22
|
||||
|
||||
### Fixed
|
||||
- Moved file logic into file-specific loaders
|
||||
|
||||
|
||||
## 0.3.0 - 2015-02-22
|
||||
|
||||
### Fixed
|
||||
- Created new classes `ConfigInterface` and `AbstractConfig` to simplify code
|
||||
|
||||
|
||||
## 0.2.1 - 2015-02-22
|
||||
|
||||
### Added
|
||||
- Array and directory support in constructor
|
||||
|
||||
### Fixed
|
||||
- Corrected deprecated usage of `Symfony\Yaml`
|
||||
|
||||
## 0.2.0 - 2015-02-21
|
||||
|
||||
### Added
|
||||
- Array and directory support in constructor
|
||||
|
||||
### Fixed
|
||||
- Now can load .YAML and .YML files
|
||||
|
||||
|
||||
## 0.1.0 - 2014-11-27
|
||||
|
||||
### Added
|
||||
- Uses PSR-4 for autoloading
|
||||
- Supports YAML
|
||||
- Now uses custom exceptions
|
||||
|
||||
|
||||
## 0.0.1 - 2014-11-19
|
||||
|
||||
### Added
|
||||
- Tagged first release
|
32
vendor/hassankhan/config/CONTRIBUTING.md
vendored
Executable file
32
vendor/hassankhan/config/CONTRIBUTING.md
vendored
Executable file
@ -0,0 +1,32 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
We accept contributions via Pull Requests on [GitHub](https://github.com/noodlehaus/config).
|
||||
|
||||
|
||||
## Pull Requests
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
|
||||
|
||||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
|
||||
|
||||
- **Use Git Flow** - Don't ask us to pull from your master branch. Set up [Git Flow](http://nvie.com/posts/a-successful-git-branching-model/) and create a new feature branch from `develop`
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
|
||||
|
||||
|
||||
## Running Tests
|
||||
|
||||
``` bash
|
||||
$ phpunit
|
||||
```
|
||||
|
||||
|
||||
**Happy coding**!
|
8
vendor/hassankhan/config/LICENSE.md
vendored
Executable file
8
vendor/hassankhan/config/LICENSE.md
vendored
Executable file
@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright © 2015 Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
36
vendor/hassankhan/config/composer.json
vendored
Executable file
36
vendor/hassankhan/config/composer.json
vendored
Executable file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "hassankhan/config",
|
||||
"type": "library",
|
||||
"description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files",
|
||||
"keywords": ["configuration", "config", "json", "yaml", "yml", "ini", "xml", "unframework", "microphp"],
|
||||
"homepage": "http://hassankhan.me/config/",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Hassan Khan",
|
||||
"role": "Developer",
|
||||
"homepage": "http://hassankhan.me/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"scrutinizer/ocular": "~1.1",
|
||||
"squizlabs/php_codesniffer": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/yaml": "~2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Noodlehaus\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Noodlehaus\\Test\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
159
vendor/hassankhan/config/src/AbstractConfig.php
vendored
Executable file
159
vendor/hassankhan/config/src/AbstractConfig.php
vendored
Executable file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus;
|
||||
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
* Abstract Config class
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
abstract class AbstractConfig implements ArrayAccess, ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Stores the configuration data
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
protected $data = null;
|
||||
|
||||
/**
|
||||
* Caches the configuration data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cache = array();
|
||||
|
||||
/**
|
||||
* Constructor method and sets default options, if any
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = array_merge($this->getDefaults(), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method in your own subclass to provide an array of default
|
||||
* options and values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function getDefaults()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* ConfigInterface Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
// Check if already cached
|
||||
if (isset($this->cache[$key])) {
|
||||
return $this->cache[$key];
|
||||
}
|
||||
|
||||
$segs = explode('.', $key);
|
||||
$root = $this->data;
|
||||
|
||||
// nested case
|
||||
foreach ($segs as $part) {
|
||||
if (isset($root[$part])) {
|
||||
$root = $root[$part];
|
||||
continue;
|
||||
} else {
|
||||
$root = $default;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// whatever we have is what we needed
|
||||
return ($this->cache[$key] = $root);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$segs = explode('.', $key);
|
||||
$root = &$this->data;
|
||||
|
||||
// Look for the key, creating nested keys if needed
|
||||
while ($part = array_shift($segs)) {
|
||||
if (!isset($root[$part]) && count($segs)) {
|
||||
$root[$part] = array();
|
||||
}
|
||||
$root = &$root[$part];
|
||||
}
|
||||
|
||||
// Assign value at target node
|
||||
$this->cache[$key] = $root = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* ArrayAccess Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets a value using the offset as a key
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a key exists
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return !is_null($this->get($offset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value using the offset as a key
|
||||
*
|
||||
* @param string $offset
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a key and its value
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->set($offset, null);
|
||||
}
|
||||
}
|
157
vendor/hassankhan/config/src/Config.php
vendored
Executable file
157
vendor/hassankhan/config/src/Config.php
vendored
Executable file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus;
|
||||
|
||||
use Noodlehaus\Exception\FileNotFoundException;
|
||||
use Noodlehaus\Exception\UnsupportedFormatException;
|
||||
use Noodlehaus\Exception\EmptyDirectoryException;
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Config extends AbstractConfig
|
||||
{
|
||||
/**
|
||||
* All file formats supported by Config
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $supportedFileParsers = array(
|
||||
'Noodlehaus\FileParser\Php',
|
||||
'Noodlehaus\FileParser\Ini',
|
||||
'Noodlehaus\FileParser\Json',
|
||||
'Noodlehaus\FileParser\Xml',
|
||||
'Noodlehaus\FileParser\Yaml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Static method for loading a Config instance.
|
||||
*
|
||||
* @param string|array $path
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
public static function load($path)
|
||||
{
|
||||
return new static($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a supported configuration file format.
|
||||
*
|
||||
* @param string|array $path
|
||||
*
|
||||
* @throws EmptyDirectoryException If `$path` is an empty directory
|
||||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$paths = $this->getValidPath($path);
|
||||
$this->data = array();
|
||||
|
||||
foreach ($paths as $path) {
|
||||
|
||||
// Get file information
|
||||
$info = pathinfo($path);
|
||||
$extension = isset($info['extension']) ? $info['extension'] : '';
|
||||
$parser = $this->getParser($extension);
|
||||
|
||||
// Try and load file
|
||||
$this->data = array_replace_recursive($this->data, $parser->parse($path));
|
||||
}
|
||||
|
||||
parent::__construct($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a parser for a given file extension
|
||||
*
|
||||
* @param string $extension
|
||||
*
|
||||
* @return Noodlehaus\File\FileInterface
|
||||
*
|
||||
* @throws UnsupportedFormatException If `$path` is an unsupported file format
|
||||
*/
|
||||
private function getParser($extension)
|
||||
{
|
||||
$parser = null;
|
||||
|
||||
foreach ($this->supportedFileParsers as $fileParser) {
|
||||
$tempParser = new $fileParser;
|
||||
|
||||
if (in_array($extension, $tempParser->getSupportedExtensions($extension))) {
|
||||
$parser = $tempParser;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If none exist, then throw an exception
|
||||
if ($parser === null) {
|
||||
throw new UnsupportedFormatException('Unsupported configuration format');
|
||||
}
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks `$path` to see if it is either an array, a directory, or a file
|
||||
*
|
||||
* @param string|array $path
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws EmptyDirectoryException If `$path` is an empty directory
|
||||
*
|
||||
* @throws FileNotFoundException If a file is not found at `$path`
|
||||
*/
|
||||
private function getValidPath($path)
|
||||
{
|
||||
// If `$path` is array
|
||||
if (is_array($path)) {
|
||||
$paths = array();
|
||||
foreach ($path as $unverifiedPath) {
|
||||
try {
|
||||
// Check if `$unverifiedPath` is optional
|
||||
// If it exists, then it's added to the list
|
||||
// If it doesn't, it throws an exception which we catch
|
||||
if ($unverifiedPath[0] !== '?') {
|
||||
$paths = array_merge($paths, $this->getValidPath($unverifiedPath));
|
||||
continue;
|
||||
}
|
||||
$optionalPath = ltrim($unverifiedPath, '?');
|
||||
$paths = array_merge($paths, $this->getValidPath($optionalPath));
|
||||
|
||||
} catch (FileNotFoundException $e) {
|
||||
// If `$unverifiedPath` is optional, then skip it
|
||||
if ($unverifiedPath[0] === '?') {
|
||||
continue;
|
||||
}
|
||||
// Otherwise rethrow the exception
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
|
||||
// If `$path` is a directory
|
||||
if (is_dir($path)) {
|
||||
$paths = glob($path . '/*.*');
|
||||
if (empty($paths)) {
|
||||
throw new EmptyDirectoryException("Configuration directory: [$path] is empty");
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
|
||||
// If `$path` is not a file, throw an exception
|
||||
if (!file_exists($path)) {
|
||||
throw new FileNotFoundException("Configuration file: [$path] cannot be found");
|
||||
}
|
||||
return array($path);
|
||||
}
|
||||
}
|
38
vendor/hassankhan/config/src/ConfigInterface.php
vendored
Executable file
38
vendor/hassankhan/config/src/ConfigInterface.php
vendored
Executable file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus;
|
||||
|
||||
/**
|
||||
* Config interface
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
interface ConfigInterface
|
||||
{
|
||||
/**
|
||||
* Gets a configuration setting using a simple or nested key.
|
||||
* Nested keys are similar to JSON paths that use the dot
|
||||
* dot notation.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null);
|
||||
|
||||
/**
|
||||
* Function for setting configuration values, using
|
||||
* either simple or nested keys.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, $value);
|
||||
}
|
9
vendor/hassankhan/config/src/Exception/EmptyDirectoryException.php
vendored
Executable file
9
vendor/hassankhan/config/src/Exception/EmptyDirectoryException.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class EmptyDirectoryException extends Exception
|
||||
{
|
||||
}
|
9
vendor/hassankhan/config/src/Exception/FileNotFoundException.php
vendored
Executable file
9
vendor/hassankhan/config/src/Exception/FileNotFoundException.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class FileNotFoundException extends Exception
|
||||
{
|
||||
}
|
20
vendor/hassankhan/config/src/Exception/ParseException.php
vendored
Executable file
20
vendor/hassankhan/config/src/Exception/ParseException.php
vendored
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\Exception;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ParseException extends ErrorException
|
||||
{
|
||||
public function __construct(array $error)
|
||||
{
|
||||
$message = $error['message'];
|
||||
$code = isset($error['code']) ? $error['code'] : 0;
|
||||
$severity = isset($error['type']) ? $error['type'] : 1;
|
||||
$filename = isset($error['file']) ? $error['file'] : __FILE__;
|
||||
$lineno = isset($error['line']) ? $error['line'] : __LINE__;
|
||||
$exception = isset($error['exception']) ? $error['exception'] : null;
|
||||
|
||||
parent::__construct($message, $code, $severity, $filename, $lineno, $exception);
|
||||
}
|
||||
}
|
9
vendor/hassankhan/config/src/Exception/UnsupportedFormatException.php
vendored
Executable file
9
vendor/hassankhan/config/src/Exception/UnsupportedFormatException.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class UnsupportedFormatException extends Exception
|
||||
{
|
||||
}
|
28
vendor/hassankhan/config/src/FileParser/AbstractFileParser.php
vendored
Executable file
28
vendor/hassankhan/config/src/FileParser/AbstractFileParser.php
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
/**
|
||||
* Abstract file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
abstract class AbstractFileParser implements FileParserInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Path to the config file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
}
|
31
vendor/hassankhan/config/src/FileParser/FileParserInterface.php
vendored
Executable file
31
vendor/hassankhan/config/src/FileParser/FileParserInterface.php
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
/**
|
||||
* Config file parser interface
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
interface FileParserInterface
|
||||
{
|
||||
/**
|
||||
* Parses a file from `$path` and gets its contents as an array
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parse($path);
|
||||
|
||||
/**
|
||||
* Returns an array of allowed file extensions for this parser
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSupportedExtensions();
|
||||
}
|
43
vendor/hassankhan/config/src/FileParser/Ini.php
vendored
Executable file
43
vendor/hassankhan/config/src/FileParser/Ini.php
vendored
Executable file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
use Noodlehaus\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* INI file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Ini implements FileParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Parses an INI file as an array
|
||||
*
|
||||
* @throws ParseException If there is an error parsing the INI file
|
||||
*/
|
||||
public function parse($path)
|
||||
{
|
||||
$data = @parse_ini_file($path, true);
|
||||
|
||||
if (!$data) {
|
||||
$error = error_get_last();
|
||||
throw new ParseException($error);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupportedExtensions()
|
||||
{
|
||||
return array('ini');
|
||||
}
|
||||
}
|
53
vendor/hassankhan/config/src/FileParser/Json.php
vendored
Executable file
53
vendor/hassankhan/config/src/FileParser/Json.php
vendored
Executable file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
use Noodlehaus\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* JSON file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Json implements FileParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Loads a JSON file as an array
|
||||
*
|
||||
* @throws ParseException If there is an error parsing the JSON file
|
||||
*/
|
||||
public function parse($path)
|
||||
{
|
||||
$data = json_decode(file_get_contents($path), true);
|
||||
|
||||
if (function_exists('json_last_error_msg')) {
|
||||
$error_message = json_last_error_msg();
|
||||
} else {
|
||||
$error_message = 'Syntax error';
|
||||
}
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$error = array(
|
||||
'message' => $error_message,
|
||||
'type' => json_last_error(),
|
||||
'file' => $path,
|
||||
);
|
||||
throw new ParseException($error);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupportedExtensions()
|
||||
{
|
||||
return array('json');
|
||||
}
|
||||
}
|
61
vendor/hassankhan/config/src/FileParser/Php.php
vendored
Executable file
61
vendor/hassankhan/config/src/FileParser/Php.php
vendored
Executable file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
use Exception;
|
||||
use Noodlehaus\Exception\ParseException;
|
||||
use Noodlehaus\Exception\UnsupportedFormatException;
|
||||
|
||||
/**
|
||||
* PHP file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Php implements FileParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Loads a PHP file and gets its' contents as an array
|
||||
*
|
||||
* @throws ParseException If the PHP file throws an exception
|
||||
* @throws UnsupportedFormatException If the PHP file does not return an array
|
||||
*/
|
||||
public function parse($path)
|
||||
{
|
||||
// Require the file, if it throws an exception, rethrow it
|
||||
try {
|
||||
$temp = require $path;
|
||||
} catch (Exception $exception) {
|
||||
throw new ParseException(
|
||||
array(
|
||||
'message' => 'PHP file threw an exception',
|
||||
'exception' => $exception,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// If we have a callable, run it and expect an array back
|
||||
if (is_callable($temp)) {
|
||||
$temp = call_user_func($temp);
|
||||
}
|
||||
|
||||
// Check for array, if its anything else, throw an exception
|
||||
if (!$temp || !is_array($temp)) {
|
||||
throw new UnsupportedFormatException('PHP file does not return an array');
|
||||
}
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupportedExtensions()
|
||||
{
|
||||
return array('php');
|
||||
}
|
||||
}
|
55
vendor/hassankhan/config/src/FileParser/Xml.php
vendored
Executable file
55
vendor/hassankhan/config/src/FileParser/Xml.php
vendored
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
use Noodlehaus\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* XML file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Xml implements FileParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Parses an XML file as an array
|
||||
*
|
||||
* @throws ParseException If there is an error parsing the XML file
|
||||
*/
|
||||
public function parse($path)
|
||||
{
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
$data = simplexml_load_file($path, null, LIBXML_NOERROR);
|
||||
|
||||
if ($data === false) {
|
||||
$errors = libxml_get_errors();
|
||||
$latestError = array_pop($errors);
|
||||
$error = array(
|
||||
'message' => $latestError->message,
|
||||
'type' => $latestError->level,
|
||||
'code' => $latestError->code,
|
||||
'file' => $latestError->file,
|
||||
'line' => $latestError->line,
|
||||
);
|
||||
throw new ParseException($error);
|
||||
}
|
||||
|
||||
$data = json_decode(json_encode($data), true);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupportedExtensions()
|
||||
{
|
||||
return array('xml');
|
||||
}
|
||||
}
|
49
vendor/hassankhan/config/src/FileParser/Yaml.php
vendored
Executable file
49
vendor/hassankhan/config/src/FileParser/Yaml.php
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Noodlehaus\FileParser;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\Yaml\Yaml as YamlParser;
|
||||
use Noodlehaus\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* YAML file parser
|
||||
*
|
||||
* @package Config
|
||||
* @author Jesus A. Domingo <jesus.domingo@gmail.com>
|
||||
* @author Hassan Khan <contact@hassankhan.me>
|
||||
* @link https://github.com/noodlehaus/config
|
||||
* @license MIT
|
||||
*/
|
||||
class Yaml implements FileParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Loads a YAML/YML file as an array
|
||||
*
|
||||
* @throws ParseException If If there is an error parsing the YAML file
|
||||
*/
|
||||
public function parse($path)
|
||||
{
|
||||
try {
|
||||
$data = YamlParser::parse($path);
|
||||
} catch (Exception $exception) {
|
||||
throw new ParseException(
|
||||
array(
|
||||
'message' => 'Error parsing YAML file',
|
||||
'exception' => $exception,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSupportedExtensions()
|
||||
{
|
||||
return array('yaml', 'yml');
|
||||
}
|
||||
}
|
5
vendor/illuminate/container/BindingResolutionException.php
vendored
Executable file
5
vendor/illuminate/container/BindingResolutionException.php
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
<?php namespace Illuminate\Container;
|
||||
|
||||
use Exception;
|
||||
|
||||
class BindingResolutionException extends Exception {}
|
1291
vendor/illuminate/container/Container.php
vendored
Executable file
1291
vendor/illuminate/container/Container.php
vendored
Executable file
File diff suppressed because it is too large
Load Diff
58
vendor/illuminate/container/ContextualBindingBuilder.php
vendored
Executable file
58
vendor/illuminate/container/ContextualBindingBuilder.php
vendored
Executable file
@ -0,0 +1,58 @@
|
||||
<?php namespace Illuminate\Container;
|
||||
|
||||
use Illuminate\Contracts\Container\ContextualBindingBuilder as ContextualBindingBuilderContract;
|
||||
|
||||
class ContextualBindingBuilder implements ContextualBindingBuilderContract {
|
||||
|
||||
/**
|
||||
* The underlying container instance.
|
||||
*
|
||||
* @var \Illuminate\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The concrete instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $concrete;
|
||||
|
||||
/**
|
||||
* Create a new contextual binding builder.
|
||||
*
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @param string $concrete
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container, $concrete)
|
||||
{
|
||||
$this->concrete = $concrete;
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the abstract target that depends on the context.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @return $this
|
||||
*/
|
||||
public function needs($abstract)
|
||||
{
|
||||
$this->needs = $abstract;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the implementation for the contextual binding.
|
||||
*
|
||||
* @param \Closure|string $implementation
|
||||
* @return void
|
||||
*/
|
||||
public function give($implementation)
|
||||
{
|
||||
$this->container->addContextualBinding($this->concrete, $this->needs, $implementation);
|
||||
}
|
||||
|
||||
}
|
31
vendor/illuminate/container/composer.json
vendored
Executable file
31
vendor/illuminate/container/composer.json
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"description": "The Illuminate Container package.",
|
||||
"license": "MIT",
|
||||
"homepage": "http://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/contracts": "5.0.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Container\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
41
vendor/illuminate/contracts/Auth/Authenticatable.php
vendored
Executable file
41
vendor/illuminate/contracts/Auth/Authenticatable.php
vendored
Executable file
@ -0,0 +1,41 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
interface Authenticatable {
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier();
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword();
|
||||
|
||||
/**
|
||||
* Get the token value for the "remember me" session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberToken();
|
||||
|
||||
/**
|
||||
* Set the token value for the "remember me" session.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value);
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName();
|
||||
|
||||
}
|
12
vendor/illuminate/contracts/Auth/CanResetPassword.php
vendored
Executable file
12
vendor/illuminate/contracts/Auth/CanResetPassword.php
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
interface CanResetPassword {
|
||||
|
||||
/**
|
||||
* Get the e-mail address where password reset links are sent.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailForPasswordReset();
|
||||
|
||||
}
|
100
vendor/illuminate/contracts/Auth/Guard.php
vendored
Executable file
100
vendor/illuminate/contracts/Auth/Guard.php
vendored
Executable file
@ -0,0 +1,100 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
interface Guard {
|
||||
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check();
|
||||
|
||||
/**
|
||||
* Determine if the current user is a guest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function guest();
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user();
|
||||
|
||||
/**
|
||||
* Log a user into the application without sessions or cookies.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function once(array $credentials = array());
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user using the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @param bool $login
|
||||
* @return bool
|
||||
*/
|
||||
public function attempt(array $credentials = array(), $remember = false, $login = true);
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using HTTP Basic Auth.
|
||||
*
|
||||
* @param string $field
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function basic($field = 'email');
|
||||
|
||||
/**
|
||||
* Perform a stateless HTTP Basic login attempt.
|
||||
*
|
||||
* @param string $field
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function onceBasic($field = 'email');
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = array());
|
||||
|
||||
/**
|
||||
* Log a user into the application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function login(Authenticatable $user, $remember = false);
|
||||
|
||||
/**
|
||||
* Log the given user ID into the application.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public function loginUsingId($id, $remember = false);
|
||||
|
||||
/**
|
||||
* Determine if the user was authenticated via "remember me" cookie.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function viaRemember();
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout();
|
||||
|
||||
}
|
76
vendor/illuminate/contracts/Auth/PasswordBroker.php
vendored
Executable file
76
vendor/illuminate/contracts/Auth/PasswordBroker.php
vendored
Executable file
@ -0,0 +1,76 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
use Closure;
|
||||
|
||||
interface PasswordBroker {
|
||||
|
||||
/**
|
||||
* Constant representing a successfully sent reminder.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const RESET_LINK_SENT = 'passwords.sent';
|
||||
|
||||
/**
|
||||
* Constant representing a successfully reset password.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const PASSWORD_RESET = 'passwords.reset';
|
||||
|
||||
/**
|
||||
* Constant representing the user not found response.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_USER = 'passwords.user';
|
||||
|
||||
/**
|
||||
* Constant representing an invalid password.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_PASSWORD = 'passwords.password';
|
||||
|
||||
/**
|
||||
* Constant representing an invalid token.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const INVALID_TOKEN = 'passwords.token';
|
||||
|
||||
/**
|
||||
* Send a password reset link to a user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure|null $callback
|
||||
* @return string
|
||||
*/
|
||||
public function sendResetLink(array $credentials, Closure $callback = null);
|
||||
|
||||
/**
|
||||
* Reset the password for the given token.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset(array $credentials, Closure $callback);
|
||||
|
||||
/**
|
||||
* Set a custom password validator.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function validator(Closure $callback);
|
||||
|
||||
/**
|
||||
* Determine if the passwords match for the request.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateNewPassword(array $credentials);
|
||||
|
||||
}
|
21
vendor/illuminate/contracts/Auth/Registrar.php
vendored
Executable file
21
vendor/illuminate/contracts/Auth/Registrar.php
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
interface Registrar {
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data);
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data);
|
||||
|
||||
}
|
48
vendor/illuminate/contracts/Auth/UserProvider.php
vendored
Executable file
48
vendor/illuminate/contracts/Auth/UserProvider.php
vendored
Executable file
@ -0,0 +1,48 @@
|
||||
<?php namespace Illuminate\Contracts\Auth;
|
||||
|
||||
interface UserProvider {
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveById($identifier);
|
||||
|
||||
/**
|
||||
* Retrieve a user by by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token);
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function updateRememberToken(Authenticatable $user, $token);
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials);
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials(Authenticatable $user, array $credentials);
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user