';
+
+ return $html;
+ }
+
+ /**
+ * Create a listing HTML element.
+ *
+ * @param string $type
+ * @param array $list
+ * @param array $attributes
+ *
+ * @return string
+ */
+ protected function listing($type, $list, $attributes = [])
+ {
+ $html = '';
+
+ if (count($list) == 0) {
+ return $html;
+ }
+
+ // Essentially we will just spin through the list and build the list of the HTML
+ // elements from the array. We will also handled nested lists in case that is
+ // present in the array. Then we will build out the final listing elements.
+ foreach ($list as $key => $value) {
+ $html .= $this->listingElement($key, $type, $value);
+ }
+
+ $attributes = $this->attributes($attributes);
+
+ return "<{$type}{$attributes}>{$html}{$type}>";
+ }
+
+ /**
+ * Create the HTML for a listing element.
+ *
+ * @param mixed $key
+ * @param string $type
+ * @param mixed $value
+ *
+ * @return string
+ */
+ protected function listingElement($key, $type, $value)
+ {
+ if (is_array($value)) {
+ return $this->nestedListing($key, $type, $value);
+ } else {
+ return '
';
+ }
+ }
+
+ /**
+ * Build an HTML attribute string from an array.
+ *
+ * @param array $attributes
+ *
+ * @return string
+ */
+ public function attributes($attributes)
+ {
+ $html = [];
+
+ foreach ((array) $attributes as $key => $value) {
+ $element = $this->attributeElement($key, $value);
+
+ if (!is_null($element)) {
+ $html[] = $element;
+ }
+ }
+
+ return count($html) > 0 ? ' '.implode(' ', $html) : '';
+ }
+
+ /**
+ * Build a single attribute element.
+ *
+ * @param string $key
+ * @param string $value
+ *
+ * @return string
+ */
+ protected function attributeElement($key, $value)
+ {
+ // For numeric keys we will assume that the key and the value are the same
+ // as this will convert HTML attributes such as "required" to a correct
+ // form like required="required" instead of using incorrect numerics.
+ if (is_numeric($key)) {
+ $key = $value;
+ }
+
+ if (!is_null($value)) {
+ return $key.'="'.e($value).'"';
+ }
+ }
+
+ /**
+ * Obfuscate a string to prevent spam-bots from sniffing it.
+ *
+ * @param string $value
+ *
+ * @return string
+ */
+ public function obfuscate($value)
+ {
+ $safe = '';
+
+ foreach (str_split($value) as $letter) {
+ if (ord($letter) > 128) {
+ return $letter;
+ }
+
+ // To properly obfuscate the value, we will randomly convert each letter to
+ // its entity or hexadecimal representation, keeping a bot from sniffing
+ // the randomly obfuscated letters out of the string on the responses.
+ switch (rand(1, 3)) {
+ case 1:
+ $safe .= ''.ord($letter).';'; break;
+
+ case 2:
+ $safe .= ''.dechex(ord($letter)).';'; break;
+
+ case 3:
+ $safe .= $letter;
+ }
+ }
+
+ return $safe;
+ }
+
+ /**
+ * Generate a meta tag.
+ *
+ * @param string $name
+ * @param string $content
+ * @param array $attributes
+ *
+ * @return string
+ */
+ public function meta($name, $content, array $attributes = [])
+ {
+ $defaults = compact('name', 'content');
+
+ $attributes = array_merge($defaults, $attributes);
+
+ return 'attributes($attributes).'>'.PHP_EOL;
+ }
+}
diff --git a/application/vendor/laravelcollective/html/src/HtmlFacade.php b/application/vendor/laravelcollective/html/src/HtmlFacade.php
new file mode 100644
index 0000000..1202359
--- /dev/null
+++ b/application/vendor/laravelcollective/html/src/HtmlFacade.php
@@ -0,0 +1,21 @@
+registerHtmlBuilder();
+
+ $this->registerFormBuilder();
+
+ $this->app->alias('html', 'Collective\Html\HtmlBuilder');
+ $this->app->alias('form', 'Collective\Html\FormBuilder');
+ }
+
+ /**
+ * Register the HTML builder instance.
+ *
+ * @return void
+ */
+ protected function registerHtmlBuilder()
+ {
+ $this->app->singleton('html', function ($app) {
+ return new HtmlBuilder($app['url']);
+ });
+ }
+
+ /**
+ * Register the form builder instance.
+ *
+ * @return void
+ */
+ protected function registerFormBuilder()
+ {
+ $this->app->singleton('form', function ($app) {
+ $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());
+
+ return $form->setSessionStore($app['session.store']);
+ });
+ }
+
+ /**
+ * Get the services provided by the provider.
+ *
+ * @return array
+ */
+ public function provides()
+ {
+ return ['html', 'form', 'Collective\Html\HtmlBuilder', 'Collective\Html\FormBuilder'];
+ }
+}
diff --git a/application/vendor/laravelcollective/html/src/helpers.php b/application/vendor/laravelcollective/html/src/helpers.php
new file mode 100644
index 0000000..b84673b
--- /dev/null
+++ b/application/vendor/laravelcollective/html/src/helpers.php
@@ -0,0 +1,69 @@
+link($url, $title, $attributes, $secure);
+ }
+}
+
+if (!function_exists('link_to_asset')) {
+ /**
+ * Generate a HTML link to an asset.
+ *
+ * @param string $url
+ * @param string $title
+ * @param array $attributes
+ * @param bool $secure
+ *
+ * @return string
+ */
+ function link_to_asset($url, $title = null, $attributes = [], $secure = null)
+ {
+ return app('html')->linkAsset($url, $title, $attributes, $secure);
+ }
+}
+
+if (!function_exists('link_to_route')) {
+ /**
+ * Generate a HTML link to a named route.
+ *
+ * @param string $name
+ * @param string $title
+ * @param array $parameters
+ * @param array $attributes
+ *
+ * @return string
+ */
+ function link_to_route($name, $title = null, $parameters = [], $attributes = [])
+ {
+ return app('html')->linkRoute($name, $title, $parameters, $attributes);
+ }
+}
+
+if (!function_exists('link_to_action')) {
+ /**
+ * Generate a HTML link to a controller action.
+ *
+ * @param string $action
+ * @param string $title
+ * @param array $parameters
+ * @param array $attributes
+ *
+ * @return string
+ */
+ function link_to_action($action, $title = null, $parameters = [], $attributes = [])
+ {
+ return app('html')->linkAction($action, $title, $parameters, $attributes);
+ }
+}
diff --git a/application/vendor/league/flysystem/LICENSE b/application/vendor/league/flysystem/LICENSE
index 308972c..f2684c8 100644
--- a/application/vendor/league/flysystem/LICENSE
+++ b/application/vendor/league/flysystem/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2013-2015 Frank de Jonge
+Copyright (c) 2013-2019 Frank de Jonge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/application/vendor/league/flysystem/README.md b/application/vendor/league/flysystem/README.md
deleted file mode 100644
index 45b7c49..0000000
--- a/application/vendor/league/flysystem/README.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# League\Flysystem
-
-[![Author](http://img.shields.io/badge/author-@frankdejonge-blue.svg?style=flat-square)](https://twitter.com/frankdejonge)
-[![Build Status](https://img.shields.io/travis/thephpleague/flysystem/master.svg?style=flat-square)](https://travis-ci.org/thephpleague/flysystem)
-[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/flysystem.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/flysystem/code-structure)
-[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/flysystem.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/flysystem)
-[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
-[![Packagist Version](https://img.shields.io/packagist/v/league/flysystem.svg?style=flat-square)](https://packagist.org/packages/league/flysystem)
-[![Total Downloads](https://img.shields.io/packagist/dt/league/flysystem.svg?style=flat-square)](https://packagist.org/packages/league/flysystem)
-
-[![SensioLabsInsight](https://insight.sensiolabs.com/projects/9820f1af-2fd0-4ab6-b42a-03e0c821e0af/big.png)](https://insight.sensiolabs.com/projects/9820f1af-2fd0-4ab6-b42a-03e0c821e0af)
-
-Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.
-
-# Goals
-
-* Have a generic API for handling common tasks across multiple file storage engines.
-* Have consistent output which you can rely on.
-* Integrate well with other packages/frameworks.
-* Be cacheable.
-* Emulate directories in systems that support none, like AwsS3.
-* Support third party plugins.
-* Make it easy to test your filesystem interactions.
-* Support streams for big file handling.
-
-# Installation
-
-Through Composer, obviously:
-
-```
-composer require league/flysystem
-```
-
-You can also use Flysystem without using Composer by registering an autoloader function:
-
-```php
-spl_autoload_register(function($class) {
- $prefix = 'League\\Flysystem\\';
-
- if ( ! substr($class, 0, 17) === $prefix) {
- return;
- }
-
- $class = substr($class, strlen($prefix));
- $location = __DIR__ . 'path/to/flysystem/src/' . str_replace('\\', '/', $class) . '.php';
-
- if (is_file($location)) {
- require_once($location);
- }
-});
-```
-
-## Integrations
-
-Want to get started quickly? Check out some of these integrations:
-
-* Laravel integration: https://github.com/GrahamCampbell/Laravel-Flysystem
-* Symfony integration: https://github.com/1up-lab/OneupFlysystemBundle
-* Zend Framework integration: https://github.com/bushbaby/BsbFlysystem
-* CakePHP integration: https://github.com/WyriHaximus/FlyPie
-* Silex integration: https://github.com/WyriHaximus/SliFly
-* Cilex integration: https://github.com/WyriHaximus/cli-fly
-* Yii 2 integration: https://github.com/creocoder/yii2-flysystem
-* Backup manager: https://github.com/heybigname/backup-manager
-
-## Adapters
-
-* Local
-* Amazon Web Services - S3 V2: https://github.com/thephpleague/flysystem-aws-s3-v2
-* Amazon Web Services - S3 V3: https://github.com/thephpleague/flysystem-aws-s3-v3
-* Rackspace Cloud Files: https://github.com/thephpleague/flysystem-rackspace
-* Dropbox: https://github.com/thephpleague/flysystem-dropbox
-* Copy: https://github.com/thephpleague/flysystem-copy
-* Ftp
-* Sftp (through phpseclib): https://github.com/thephpleague/flysystem-sftp
-* Zip (through ZipArchive): https://github.com/thephpleague/flysystem-ziparchive
-* WebDAV (through SabreDAV): https://github.com/thephpleague/flysystem-webdav
-* PHPCR: https://github.com/thephpleague/flysystem-phpcr
-* Azure Blob Storage
-* NullAdapter
-
-## Caching
-
-* Memory (array caching)
-* Redis (through Predis)
-* Memcached
-* Adapter
-* Stash
-
-## Documentation
-
-[Check out the documentation](http://flysystem.thephpleague.com/)
-
-## Security
-
-If you discover any security related issues, please email frenky@frenky.net instead of using the issue tracker.
-
-
-# Enjoy
-
-Oh and if you've come down this far, you might as well follow me on [twitter](http://twitter.com/frankdejonge).
diff --git a/application/vendor/league/flysystem/composer.json b/application/vendor/league/flysystem/composer.json
index dab5d14..84229e9 100644
--- a/application/vendor/league/flysystem/composer.json
+++ b/application/vendor/league/flysystem/composer.json
@@ -14,14 +14,12 @@
}
],
"require": {
- "php": ">=5.4.0"
+ "php": ">=5.5.9",
+ "ext-fileinfo": "*"
},
"require-dev": {
- "ext-fileinfo": "*",
- "phpunit/phpunit": "~4.1",
- "mockery/mockery": "~0.9",
- "phpspec/phpspec": "^2.2",
- "phpspec/prophecy-phpunit": "~1.0"
+ "phpspec/phpspec": "^3.4",
+ "phpunit/phpunit": "^5.7.10"
},
"autoload": {
"psr-4": {
@@ -31,31 +29,36 @@
"autoload-dev": {
"psr-4": {
"League\\Flysystem\\Stub\\": "stub/"
- }
+ },
+ "files": [
+ "tests/PHPUnitHacks.php"
+ ]
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
- "league/flysystem-copy": "Allows you to use Copy.com storage",
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
"league/flysystem-webdav": "Allows you to use WebDAV storage",
"league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
"league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
- "league/flysystem-dropbox": "Allows you to use Dropbox storage",
+ "spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
+ "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications",
"league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
+ "ext-ftp": "Allows you to use FTP server storage",
+ "ext-openssl": "Allows you to use FTPS server storage",
"league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter"
},
"conflict": {
"league/flysystem-sftp": "<1.0.6"
},
- "config": {
- "bin-dir": "bin"
- },
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
+ },
+ "scripts": {
+ "phpstan": "php phpstan.php"
}
}
diff --git a/application/vendor/league/flysystem/deprecations.md b/application/vendor/league/flysystem/deprecations.md
new file mode 100644
index 0000000..c336a42
--- /dev/null
+++ b/application/vendor/league/flysystem/deprecations.md
@@ -0,0 +1,19 @@
+# Deprecations
+
+This document lists all the planned deprecations.
+
+## Handlers will be removed in 2.0
+
+The `Handler` type and associated calls will be removed in version 2.0.
+
+### Upgrade path
+
+You should create your own implementation for handling OOP usage,
+but it's recommended to move away from using an OOP-style wrapper entirely.
+
+The reason for this is that it's too easy for implementation details (for
+your application this is Flysystem) to leak into the application. The most
+important part for Flysystem is that it improves portability and creates a
+solid boundary between your application core and the infrastructure you use.
+The OOP-style handling breaks this principle, therefore I want to stop
+promoting it.
diff --git a/application/vendor/league/flysystem/src/Adapter/AbstractAdapter.php b/application/vendor/league/flysystem/src/Adapter/AbstractAdapter.php
index 4617c95..e577ac4 100644
--- a/application/vendor/league/flysystem/src/Adapter/AbstractAdapter.php
+++ b/application/vendor/league/flysystem/src/Adapter/AbstractAdapter.php
@@ -7,7 +7,7 @@
abstract class AbstractAdapter implements AdapterInterface
{
/**
- * @var string path prefix
+ * @var string|null path prefix
*/
protected $pathPrefix;
@@ -21,23 +21,25 @@ abstract class AbstractAdapter implements AdapterInterface
*
* @param string $prefix
*
- * @return self
+ * @return void
*/
public function setPathPrefix($prefix)
{
- $is_empty = empty($prefix);
+ $prefix = (string) $prefix;
- if (! $is_empty) {
- $prefix = rtrim($prefix, $this->pathSeparator).$this->pathSeparator;
+ if ($prefix === '') {
+ $this->pathPrefix = null;
+
+ return;
}
- $this->pathPrefix = $is_empty ? null : $prefix;
+ $this->pathPrefix = rtrim($prefix, '\\/') . $this->pathSeparator;
}
/**
* Get the path prefix.
*
- * @return string path prefix
+ * @return string|null path prefix or null if pathPrefix is empty
*/
public function getPathPrefix()
{
@@ -53,17 +55,7 @@ public function getPathPrefix()
*/
public function applyPathPrefix($path)
{
- $path = ltrim($path, '\\/');
-
- if (strlen($path) === 0) {
- return $this->getPathPrefix() ?: '';
- }
-
- if ($prefix = $this->getPathPrefix()) {
- $path = $prefix.$path;
- }
-
- return $path;
+ return $this->getPathPrefix() . ltrim($path, '\\/');
}
/**
@@ -75,12 +67,6 @@ public function applyPathPrefix($path)
*/
public function removePathPrefix($path)
{
- $pathPrefix = $this->getPathPrefix();
-
- if ($pathPrefix === null) {
- return $path;
- }
-
- return substr($path, strlen($pathPrefix));
+ return substr($path, strlen($this->getPathPrefix()));
}
}
diff --git a/application/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php b/application/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php
index 102eab4..578b491 100644
--- a/application/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php
+++ b/application/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php
@@ -6,6 +6,8 @@
use League\Flysystem\AdapterInterface;
use League\Flysystem\Config;
use League\Flysystem\NotSupportedException;
+use League\Flysystem\SafeStorage;
+use RuntimeException;
abstract class AbstractFtpAdapter extends AbstractAdapter
{
@@ -24,16 +26,6 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
*/
protected $port = 21;
- /**
- * @var string|null
- */
- protected $username;
-
- /**
- * @var string|null
- */
- protected $password;
-
/**
* @var bool
*/
@@ -79,6 +71,18 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
*/
protected $systemType;
+ /**
+ * @var SafeStorage
+ */
+ protected $safeStorage;
+
+ /**
+ * True to enable timestamps for FTP servers that return unix-style listings.
+ *
+ * @var bool
+ */
+ protected $enableTimestampsOnUnixListings = false;
+
/**
* Constructor.
*
@@ -86,6 +90,7 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
*/
public function __construct(array $config)
{
+ $this->safeStorage = new SafeStorage();
$this->setConfig($config);
}
@@ -99,11 +104,11 @@ public function __construct(array $config)
public function setConfig(array $config)
{
foreach ($this->configurable as $setting) {
- if (! isset($config[$setting])) {
+ if ( ! isset($config[$setting])) {
continue;
}
- $method = 'set'.ucfirst($setting);
+ $method = 'set' . ucfirst($setting);
if (method_exists($this, $method)) {
$this->$method($config[$setting]);
@@ -208,7 +213,7 @@ public function setPort($port)
*/
public function setRoot($root)
{
- $this->root = rtrim($root, '\\/').$this->separator;
+ $this->root = rtrim($root, '\\/') . $this->separator;
return $this;
}
@@ -220,7 +225,9 @@ public function setRoot($root)
*/
public function getUsername()
{
- return empty($this->username) ? 'anonymous' : $this->username;
+ $username = $this->safeStorage->retrieveSafely('username');
+
+ return $username !== null ? $username : 'anonymous';
}
/**
@@ -232,7 +239,7 @@ public function getUsername()
*/
public function setUsername($username)
{
- $this->username = $username;
+ $this->safeStorage->storeSafely('username', $username);
return $this;
}
@@ -244,7 +251,7 @@ public function setUsername($username)
*/
public function getPassword()
{
- return $this->password;
+ return $this->safeStorage->retrieveSafely('password');
}
/**
@@ -256,7 +263,7 @@ public function getPassword()
*/
public function setPassword($password)
{
- $this->password = $password;
+ $this->safeStorage->storeSafely('password', $password);
return $this;
}
@@ -309,6 +316,20 @@ public function setSystemType($systemType)
return $this;
}
+ /**
+ * True to enable timestamps for FTP servers that return unix-style listings.
+ *
+ * @param bool $bool
+ *
+ * @return $this
+ */
+ public function setEnableTimestampsOnUnixListings($bool = false)
+ {
+ $this->enableTimestampsOnUnixListings = $bool;
+
+ return $this;
+ }
+
/**
* @inheritdoc
*/
@@ -317,6 +338,8 @@ public function listContents($directory = '', $recursive = false)
return $this->listDirectoryContents($directory, $recursive);
}
+ abstract protected function listDirectoryContents($directory, $recursive = false);
+
/**
* Normalize a directory listing.
*
@@ -333,7 +356,7 @@ protected function normalizeListing(array $listing, $prefix = '')
while ($item = array_shift($listing)) {
if (preg_match('#^.*:$#', $item)) {
- $base = trim($item, ':');
+ $base = preg_replace('~^\./*|:$~', '', $item);
continue;
}
@@ -387,6 +410,18 @@ protected function normalizeObject($item, $base)
/**
* Normalize a Unix file entry.
*
+ * Given $item contains:
+ * '-rw-r--r-- 1 ftp ftp 409 Aug 19 09:01 file1.txt'
+ *
+ * This function will return:
+ * [
+ * 'type' => 'file',
+ * 'path' => 'file1.txt',
+ * 'visibility' => 'public',
+ * 'size' => 409,
+ * 'timestamp' => 1566205260
+ * ]
+ *
* @param string $item
* @param string $base
*
@@ -395,9 +430,14 @@ protected function normalizeObject($item, $base)
protected function normalizeUnixObject($item, $base)
{
$item = preg_replace('#\s+#', ' ', trim($item), 7);
- list($permissions, /* $number */, /* $owner */, /* $group */, $size, /* $month */, /* $day */, /* $time*/, $name) = explode(' ', $item, 9);
+
+ if (count(explode(' ', $item, 9)) !== 9) {
+ throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
+ }
+
+ list($permissions, /* $number */, /* $owner */, /* $group */, $size, $month, $day, $timeOrYear, $name) = explode(' ', $item, 9);
$type = $this->detectType($permissions);
- $path = empty($base) ? $name : $base.$this->separator.$name;
+ $path = $base === '' ? $name : $base . $this->separator . $name;
if ($type === 'dir') {
return compact('type', 'path');
@@ -407,7 +447,44 @@ protected function normalizeUnixObject($item, $base)
$visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
$size = (int) $size;
- return compact('type', 'path', 'visibility', 'size');
+ $result = compact('type', 'path', 'visibility', 'size');
+ if ($this->enableTimestampsOnUnixListings) {
+ $timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
+ $result += compact('timestamp');
+ }
+
+ return $result;
+ }
+
+ /**
+ * Only accurate to the minute (current year), or to the day.
+ *
+ * Inadequacies in timestamp accuracy are due to limitations of the FTP 'LIST' command
+ *
+ * Note: The 'MLSD' command is a machine-readable replacement for 'LIST'
+ * but many FTP servers do not support it :(
+ *
+ * @param string $month e.g. 'Aug'
+ * @param string $day e.g. '19'
+ * @param string $timeOrYear e.g. '09:01' OR '2015'
+ *
+ * @return int
+ */
+ protected function normalizeUnixTimestamp($month, $day, $timeOrYear)
+ {
+ if (is_numeric($timeOrYear)) {
+ $year = $timeOrYear;
+ $hour = '00';
+ $minute = '00';
+ $seconds = '00';
+ } else {
+ $year = date('Y');
+ list($hour, $minute) = explode(':', $timeOrYear);
+ $seconds = '00';
+ }
+ $dateTime = DateTime::createFromFormat('Y-M-j-G:i:s', "{$year}-{$month}-{$day}-{$hour}:{$minute}:{$seconds}");
+
+ return $dateTime->getTimestamp();
}
/**
@@ -421,12 +498,18 @@ protected function normalizeUnixObject($item, $base)
protected function normalizeWindowsObject($item, $base)
{
$item = preg_replace('#\s+#', ' ', trim($item), 3);
+
+ if (count(explode(' ', $item, 4)) !== 4) {
+ throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
+ }
+
list($date, $time, $size, $name) = explode(' ', $item, 4);
- $path = empty($base) ? $name : $base.$this->separator.$name;
+ $path = $base === '' ? $name : $base . $this->separator . $name;
// Check for the correct date/time format
$format = strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i';
- $timestamp = DateTime::createFromFormat($format, $date.$time)->getTimestamp();
+ $dt = DateTime::createFromFormat($format, $date . $time);
+ $timestamp = $dt ? $dt->getTimestamp() : (int) strtotime("$date $time");
if ($size === '') {
$type = 'dir';
@@ -450,11 +533,7 @@ protected function normalizeWindowsObject($item, $base)
*/
protected function detectSystemType($item)
{
- if (preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item)) {
- return $this->systemType = 'windows';
- }
-
- return $this->systemType = 'unix';
+ return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item) ? 'windows' : 'unix';
}
/**
@@ -493,8 +572,8 @@ protected function normalizePermissions($permissions)
return array_sum(str_split($part));
};
- // get the sum of the groups
- return array_sum(array_map($mapper, $parts));
+ // converts to decimal number
+ return octdec(implode('', array_map($mapper, $parts)));
}
/**
@@ -507,11 +586,7 @@ protected function normalizePermissions($permissions)
public function removeDotDirectories(array $list)
{
$filter = function ($line) {
- if (! empty($line) && !preg_match('#.* \.(\.)?$|^total#', $line)) {
- return true;
- }
-
- return false;
+ return $line !== '' && ! preg_match('#.* \.(\.)?$|^total#', $line);
};
return array_filter($list, $filter);
@@ -548,7 +623,9 @@ public function getVisibility($path)
*/
public function ensureDirectory($dirname)
{
- if (! empty($dirname) && !$this->has($dirname)) {
+ $dirname = (string) $dirname;
+
+ if ($dirname !== '' && ! $this->has($dirname)) {
$this->createDir($dirname, new Config());
}
}
@@ -558,7 +635,10 @@ public function ensureDirectory($dirname)
*/
public function getConnection()
{
- if (! $this->isConnected()) {
+ $tries = 0;
+
+ while ( ! $this->isConnected() && $tries < 3) {
+ $tries++;
$this->disconnect();
$this->connect();
}
diff --git a/application/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php b/application/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php
new file mode 100644
index 0000000..fd8d216
--- /dev/null
+++ b/application/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php
@@ -0,0 +1,12 @@
+passive = $passive;
}
+ /**
+ * @param bool $ignorePassiveAddress
+ */
+ public function setIgnorePassiveAddress($ignorePassiveAddress)
+ {
+ $this->ignorePassiveAddress = $ignorePassiveAddress;
+ }
+
+ /**
+ * @param bool $recurseManually
+ */
+ public function setRecurseManually($recurseManually)
+ {
+ $this->recurseManually = $recurseManually;
+ }
+
+ /**
+ * @param bool $utf8
+ */
+ public function setUtf8($utf8)
+ {
+ $this->utf8 = (bool) $utf8;
+ }
+
/**
* Connect to the FTP server.
*/
@@ -84,13 +134,30 @@ public function connect()
$this->connection = ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
}
- if (! $this->connection) {
+ if ( ! $this->connection) {
throw new RuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
}
$this->login();
+ $this->setUtf8Mode();
$this->setConnectionPassiveMode();
$this->setConnectionRoot();
+ $this->isPureFtpd = $this->isPureFtpdServer();
+ }
+
+ /**
+ * Set the connection to UTF-8 mode.
+ */
+ protected function setUtf8Mode()
+ {
+ if ($this->utf8) {
+ $response = ftp_raw($this->connection, "OPTS UTF8 ON");
+ if (substr($response[0], 0, 3) !== '200') {
+ throw new RuntimeException(
+ 'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort()
+ );
+ }
+ }
}
/**
@@ -100,7 +167,11 @@ public function connect()
*/
protected function setConnectionPassiveMode()
{
- if (! ftp_pasv($this->connection, $this->passive)) {
+ if (is_bool($this->ignorePassiveAddress) && defined('FTP_USEPASVADDRESS')) {
+ ftp_set_option($this->connection, FTP_USEPASVADDRESS, ! $this->ignorePassiveAddress);
+ }
+
+ if ( ! ftp_pasv($this->connection, $this->passive)) {
throw new RuntimeException(
'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
);
@@ -115,7 +186,7 @@ protected function setConnectionRoot()
$root = $this->getRoot();
$connection = $this->connection;
- if (empty($root) === false && ! ftp_chdir($connection, $root)) {
+ if ($root && ! ftp_chdir($connection, $root)) {
throw new RuntimeException('Root is invalid or does not exist: ' . $this->getRoot());
}
@@ -133,14 +204,16 @@ protected function setConnectionRoot()
*/
protected function login()
{
- set_error_handler(
- function () {
- }
+ set_error_handler(function () {
+ });
+ $isLoggedIn = ftp_login(
+ $this->connection,
+ $this->getUsername(),
+ $this->getPassword()
);
- $isLoggedIn = ftp_login($this->connection, $this->getUsername(), $this->getPassword());
restore_error_handler();
- if (! $isLoggedIn) {
+ if ( ! $isLoggedIn) {
$this->disconnect();
throw new RuntimeException(
'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort(
@@ -154,7 +227,7 @@ function () {
*/
public function disconnect()
{
- if ($this->isConnected()) {
+ if (is_resource($this->connection)) {
ftp_close($this->connection);
}
@@ -177,7 +250,7 @@ public function write($path, $contents, Config $config)
}
$result['contents'] = $contents;
- $result['mimetype'] = Util::guessMimeType($path, $contents);
+ $result['mimetype'] = $config->get('mimetype') ?: Util::guessMimeType($path, $contents);
return $result;
}
@@ -189,7 +262,7 @@ public function writeStream($path, $resource, Config $config)
{
$this->ensureDirectory(Util::dirname($path));
- if (! ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
+ if ( ! ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
return false;
}
@@ -197,7 +270,9 @@ public function writeStream($path, $resource, Config $config)
$this->setVisibility($path, $visibility);
}
- return compact('path', 'visibility');
+ $type = 'file';
+
+ return compact('type', 'path', 'visibility');
}
/**
@@ -238,14 +313,14 @@ public function delete($path)
public function deleteDir($dirname)
{
$connection = $this->getConnection();
- $contents = array_reverse($this->listDirectoryContents($dirname));
+ $contents = array_reverse($this->listDirectoryContents($dirname, false));
foreach ($contents as $object) {
if ($object['type'] === 'file') {
- if (! ftp_delete($connection, $object['path'])) {
+ if ( ! ftp_delete($connection, $object['path'])) {
return false;
}
- } elseif (! ftp_rmdir($connection, $object['path'])) {
+ } elseif ( ! $this->deleteDir($object['path'])) {
return false;
}
}
@@ -273,7 +348,7 @@ public function createDir($dirname, Config $config)
$this->setConnectionRoot();
- return ['path' => $dirname];
+ return ['type' => 'dir', 'path' => $dirname];
}
/**
@@ -287,7 +362,7 @@ public function createDir($dirname, Config $config)
protected function createActualDirectory($directory, $connection)
{
// List the current directory
- $listing = ftp_nlist($connection, '.');
+ $listing = ftp_nlist($connection, '.') ?: [];
foreach ($listing as $key => $item) {
if (preg_match('~^\./.*~', $item)) {
@@ -295,7 +370,7 @@ protected function createActualDirectory($directory, $connection)
}
}
- if (in_array($directory, $listing)) {
+ if (in_array($directory, $listing, true)) {
return true;
}
@@ -307,24 +382,30 @@ protected function createActualDirectory($directory, $connection)
*/
public function getMetadata($path)
{
- $connection = $this->getConnection();
-
if ($path === '') {
return ['type' => 'dir', 'path' => ''];
}
- if (@ftp_chdir($connection, $path) === true) {
+ if (@ftp_chdir($this->getConnection(), $path) === true) {
$this->setConnectionRoot();
return ['type' => 'dir', 'path' => $path];
}
- $listing = ftp_rawlist($connection, $path);
+ $listing = $this->ftpRawlist('-A', str_replace('*', '\\*', $path));
+
+ if (empty($listing) || in_array('total 0', $listing, true)) {
+ return false;
+ }
- if (empty($listing)) {
+ if (preg_match('/.* not found/', $listing[0])) {
return false;
}
+ if (preg_match('/^total [0-9]*$/', $listing[0])) {
+ array_shift($listing);
+ }
+
return $this->normalizeObject($listing[0], '');
}
@@ -333,11 +414,11 @@ public function getMetadata($path)
*/
public function getMimetype($path)
{
- if (! $metadata = $this->read($path)) {
+ if ( ! $metadata = $this->getMetadata($path)) {
return false;
}
- $metadata['mimetype'] = Util::guessMimeType($path, $metadata['contents']);
+ $metadata['mimetype'] = MimeType::detectByFilename($path);
return $metadata;
}
@@ -349,7 +430,7 @@ public function getTimestamp($path)
{
$timestamp = ftp_mdtm($this->getConnection(), $path);
- return ($timestamp !== -1) ? ['timestamp' => $timestamp] : false;
+ return ($timestamp !== -1) ? ['path' => $path, 'timestamp' => $timestamp] : false;
}
/**
@@ -357,7 +438,7 @@ public function getTimestamp($path)
*/
public function read($path)
{
- if (! $object = $this->readStream($path)) {
+ if ( ! $object = $this->readStream($path)) {
return false;
}
@@ -373,17 +454,17 @@ public function read($path)
*/
public function readStream($path)
{
- $stream = fopen('php://temp', 'w+');
+ $stream = fopen('php://temp', 'w+b');
$result = ftp_fget($this->getConnection(), $stream, $path, $this->transferMode);
rewind($stream);
- if (! $result) {
+ if ( ! $result) {
fclose($stream);
return false;
}
- return compact('stream');
+ return ['type' => 'file', 'path' => $path, 'stream' => $stream];
}
/**
@@ -393,11 +474,11 @@ public function setVisibility($path, $visibility)
{
$mode = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? $this->getPermPublic() : $this->getPermPrivate();
- if (! ftp_chmod($this->getConnection(), $mode, $path)) {
+ if ( ! ftp_chmod($this->getConnection(), $mode, $path)) {
return false;
}
- return compact('visibility');
+ return compact('path', 'visibility');
}
/**
@@ -407,18 +488,85 @@ public function setVisibility($path, $visibility)
*/
protected function listDirectoryContents($directory, $recursive = true)
{
- $listing = ftp_rawlist($this->getConnection(), '-lna ' . $directory, $recursive);
+ $directory = str_replace('*', '\\*', $directory);
+
+ if ($recursive && $this->recurseManually) {
+ return $this->listDirectoryContentsRecursive($directory);
+ }
+
+ $options = $recursive ? '-alnR' : '-aln';
+ $listing = $this->ftpRawlist($options, $directory);
return $listing ? $this->normalizeListing($listing, $directory) : [];
}
+ /**
+ * @inheritdoc
+ *
+ * @param string $directory
+ */
+ protected function listDirectoryContentsRecursive($directory)
+ {
+ $listing = $this->normalizeListing($this->ftpRawlist('-aln', $directory) ?: [], $directory);
+ $output = [];
+
+ foreach ($listing as $item) {
+ $output[] = $item;
+ if ($item['type'] !== 'dir') {
+ continue;
+ }
+ $output = array_merge($output, $this->listDirectoryContentsRecursive($item['path']));
+ }
+
+ return $output;
+ }
+
/**
* Check if the connection is open.
*
* @return bool
+ *
+ * @throws ErrorException
*/
public function isConnected()
{
- return ! is_null($this->connection) && ftp_systype($this->connection) !== false;
+ try {
+ return is_resource($this->connection) && ftp_rawlist($this->connection, $this->getRoot()) !== false;
+ } catch (ErrorException $e) {
+ if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
+ throw $e;
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ protected function isPureFtpdServer()
+ {
+ $response = ftp_raw($this->connection, 'HELP');
+
+ return stripos(implode(' ', $response), 'Pure-FTPd') !== false;
+ }
+
+ /**
+ * The ftp_rawlist function with optional escaping.
+ *
+ * @param string $options
+ * @param string $path
+ *
+ * @return array
+ */
+ protected function ftpRawlist($options, $path)
+ {
+ $connection = $this->getConnection();
+
+ if ($this->isPureFtpd) {
+ $path = str_replace(' ', '\ ', $path);
+ }
+
+ return ftp_rawlist($connection, $options . ' ' . $path);
}
}
diff --git a/application/vendor/league/flysystem/src/Adapter/Ftpd.php b/application/vendor/league/flysystem/src/Adapter/Ftpd.php
index b7ac88d..d5349e4 100644
--- a/application/vendor/league/flysystem/src/Adapter/Ftpd.php
+++ b/application/vendor/league/flysystem/src/Adapter/Ftpd.php
@@ -9,7 +9,16 @@ class Ftpd extends Ftp
*/
public function getMetadata($path)
{
- if (empty($path) || !($object = ftp_raw($this->getConnection(), 'STAT '.$path)) || count($object) < 3) {
+ if ($path === '') {
+ return ['type' => 'dir', 'path' => ''];
+ }
+ if (@ftp_chdir($this->getConnection(), $path) === true) {
+ $this->setConnectionRoot();
+
+ return ['type' => 'dir', 'path' => $path];
+ }
+
+ if ( ! ($object = ftp_raw($this->getConnection(), 'STAT ' . $path)) || count($object) < 3) {
return false;
}
@@ -27,7 +36,7 @@ protected function listDirectoryContents($directory, $recursive = true)
{
$listing = ftp_rawlist($this->getConnection(), $directory, $recursive);
- if ($listing === false || (!empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) {
+ if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) {
return [];
}
diff --git a/application/vendor/league/flysystem/src/Adapter/Local.php b/application/vendor/league/flysystem/src/Adapter/Local.php
index f5ed5d4..c6e6fa8 100644
--- a/application/vendor/league/flysystem/src/Adapter/Local.php
+++ b/application/vendor/league/flysystem/src/Adapter/Local.php
@@ -4,11 +4,13 @@
use DirectoryIterator;
use FilesystemIterator;
-use Finfo;
-use League\Flysystem\AdapterInterface;
+use finfo as Finfo;
use League\Flysystem\Config;
+use League\Flysystem\Exception;
use League\Flysystem\NotSupportedException;
+use League\Flysystem\UnreadableFileException;
use League\Flysystem\Util;
+use LogicException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use SplFileInfo;
@@ -30,13 +32,13 @@ class Local extends AbstractAdapter
*/
protected static $permissions = [
'file' => [
- 'public' => 0744,
- 'private' => 0700,
+ 'public' => 0644,
+ 'private' => 0600,
],
'dir' => [
'public' => 0755,
'private' => 0700,
- ]
+ ],
];
/**
@@ -53,6 +55,7 @@ class Local extends AbstractAdapter
* @var int
*/
protected $writeFlags;
+
/**
* @var int
*/
@@ -65,18 +68,20 @@ class Local extends AbstractAdapter
* @param int $writeFlags
* @param int $linkHandling
* @param array $permissions
+ *
+ * @throws LogicException
*/
public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = [])
{
- // permissionMap needs to be set before ensureDirectory() is called.
+ $root = is_link($root) ? realpath($root) : $root;
$this->permissionMap = array_replace_recursive(static::$permissions, $permissions);
- $realRoot = $this->ensureDirectory($root);
+ $this->ensureDirectory($root);
- if (! is_dir($realRoot) || !is_readable($realRoot)) {
- throw new \LogicException('The root path '.$root.' is not readable.');
+ if ( ! is_dir($root) || ! is_readable($root)) {
+ throw new LogicException('The root path ' . $root . ' is not readable.');
}
- $this->setPathPrefix($realRoot);
+ $this->setPathPrefix($root);
$this->writeFlags = $writeFlags;
$this->linkHandling = $linkHandling;
}
@@ -86,17 +91,27 @@ public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::
*
* @param string $root root directory path
*
- * @return string real path to root
+ * @return void
+ *
+ * @throws Exception in case the root directory can not be created
*/
protected function ensureDirectory($root)
{
- if (! is_dir($root)) {
+ if ( ! is_dir($root)) {
$umask = umask(0);
- mkdir($root, $this->permissionMap['dir']['public'], true);
+
+ if ( ! @mkdir($root, $this->permissionMap['dir']['public'], true)) {
+ $mkdirError = error_get_last();
+ }
+
umask($umask);
- }
+ clearstatcache(false, $root);
- return realpath($root);
+ if ( ! is_dir($root)) {
+ $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
+ throw new Exception(sprintf('Impossible to create the root directory "%s". %s', $root, $errorMessage));
+ }
+ }
}
/**
@@ -139,23 +154,21 @@ public function writeStream($path, $resource, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
- $stream = fopen($location, 'w+');
+ $stream = fopen($location, 'w+b');
- if (! $stream) {
+ if ( ! $stream || stream_copy_to_stream($resource, $stream) === false || ! fclose($stream)) {
return false;
}
- stream_copy_to_stream($resource, $stream);
-
- if (! fclose($stream)) {
- return false;
- }
+ $type = 'file';
+ $result = compact('type', 'path');
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
+ $result['visibility'] = $visibility;
}
- return compact('path', 'visibility');
+ return $result;
}
/**
@@ -164,9 +177,9 @@ public function writeStream($path, $resource, Config $config)
public function readStream($path)
{
$location = $this->applyPathPrefix($path);
- $stream = fopen($location, 'r');
+ $stream = fopen($location, 'rb');
- return compact('stream', 'path');
+ return ['type' => 'file', 'path' => $path, 'stream' => $stream];
}
/**
@@ -183,14 +196,21 @@ public function updateStream($path, $resource, Config $config)
public function update($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
- $mimetype = Util::guessMimeType($path, $contents);
$size = file_put_contents($location, $contents, $this->writeFlags);
if ($size === false) {
return false;
}
- return compact('path', 'size', 'contents', 'mimetype');
+ $type = 'file';
+
+ $result = compact('type', 'path', 'size', 'contents');
+
+ if ($mimetype = $config->get('mimetype') ?: Util::guessMimeType($path, $contents)) {
+ $result['mimetype'] = $mimetype;
+ }
+
+ return $result;
}
/**
@@ -199,13 +219,13 @@ public function update($path, $contents, Config $config)
public function read($path)
{
$location = $this->applyPathPrefix($path);
- $contents = file_get_contents($location);
+ $contents = @file_get_contents($location);
if ($contents === false) {
return false;
}
- return compact('contents', 'path');
+ return ['type' => 'file', 'path' => $path, 'contents' => $contents];
}
/**
@@ -240,7 +260,7 @@ public function delete($path)
{
$location = $this->applyPathPrefix($path);
- return unlink($location);
+ return @unlink($location);
}
/**
@@ -249,9 +269,9 @@ public function delete($path)
public function listContents($directory = '', $recursive = false)
{
$result = [];
- $location = $this->applyPathPrefix($directory).$this->pathSeparator;
+ $location = $this->applyPathPrefix($directory);
- if (! is_dir($location)) {
+ if ( ! is_dir($location)) {
return [];
}
@@ -276,6 +296,7 @@ public function listContents($directory = '', $recursive = false)
public function getMetadata($path)
{
$location = $this->applyPathPrefix($path);
+ clearstatcache(false, $location);
$info = new SplFileInfo($location);
return $this->normalizeFileInfo($info);
@@ -296,8 +317,13 @@ public function getMimetype($path)
{
$location = $this->applyPathPrefix($path);
$finfo = new Finfo(FILEINFO_MIME_TYPE);
+ $mimetype = $finfo->file($location);
- return ['mimetype' => $finfo->file($location)];
+ if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty', 'application/x-empty'])) {
+ $mimetype = Util\MimeType::detectByFilename($location);
+ }
+
+ return ['path' => $path, 'type' => 'file', 'mimetype' => $mimetype];
}
/**
@@ -316,9 +342,17 @@ public function getVisibility($path)
$location = $this->applyPathPrefix($path);
clearstatcache(false, $location);
$permissions = octdec(substr(sprintf('%o', fileperms($location)), -4));
- $visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
+ $type = is_dir($location) ? 'dir' : 'file';
- return compact('visibility');
+ foreach ($this->permissionMap[$type] as $visibility => $visibilityPermissions) {
+ if ($visibilityPermissions == $permissions) {
+ return compact('path', 'visibility');
+ }
+ }
+
+ $visibility = substr(sprintf('%o', fileperms($location)), -4);
+
+ return compact('path', 'visibility');
}
/**
@@ -328,9 +362,13 @@ public function setVisibility($path, $visibility)
{
$location = $this->applyPathPrefix($path);
$type = is_dir($location) ? 'dir' : 'file';
- chmod($location, $this->permissionMap[$type][$visibility]);
+ $success = chmod($location, $this->permissionMap[$type][$visibility]);
+
+ if ($success === false) {
+ return false;
+ }
- return compact('visibility');
+ return compact('path', 'visibility');
}
/**
@@ -341,11 +379,13 @@ public function createDir($dirname, Config $config)
$location = $this->applyPathPrefix($dirname);
$umask = umask(0);
$visibility = $config->get('visibility', 'public');
+ $return = ['path' => $dirname, 'type' => 'dir'];
- if (! is_dir($location) && !mkdir($location, $this->permissionMap['dir'][$visibility], true)) {
- $return = false;
- } else {
- $return = ['path' => $dirname, 'type' => 'dir'];
+ if ( ! is_dir($location)) {
+ if (false === @mkdir($location, $this->permissionMap['dir'][$visibility], true)
+ || false === is_dir($location)) {
+ $return = false;
+ }
}
umask($umask);
@@ -360,42 +400,50 @@ public function deleteDir($dirname)
{
$location = $this->applyPathPrefix($dirname);
- if (! is_dir($location)) {
+ if ( ! is_dir($location)) {
return false;
}
- $contents = new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($location, FilesystemIterator::SKIP_DOTS),
- RecursiveIteratorIterator::CHILD_FIRST
- );
+ $contents = $this->getRecursiveDirectoryIterator($location, RecursiveIteratorIterator::CHILD_FIRST);
/** @var SplFileInfo $file */
foreach ($contents as $file) {
- switch ($file->getType()) {
- case 'dir':
- rmdir($file->getRealPath());
- break;
- case 'link':
- unlink($file->getPathname());
- break;
- default:
- unlink($file->getRealPath());
- }
+ $this->guardAgainstUnreadableFileInfo($file);
+ $this->deleteFileInfoObject($file);
}
return rmdir($location);
}
+ /**
+ * @param SplFileInfo $file
+ */
+ protected function deleteFileInfoObject(SplFileInfo $file)
+ {
+ switch ($file->getType()) {
+ case 'dir':
+ rmdir($file->getRealPath());
+ break;
+ case 'link':
+ unlink($file->getPathname());
+ break;
+ default:
+ unlink($file->getRealPath());
+ }
+ }
+
/**
* Normalize the file info.
*
* @param SplFileInfo $file
*
- * @return array
+ * @return array|void
+ *
+ * @throws NotSupportedException
*/
protected function normalizeFileInfo(SplFileInfo $file)
{
- if (! $file->isLink()) {
+ if ( ! $file->isLink()) {
return $this->mapFileInfo($file);
}
@@ -421,15 +469,16 @@ protected function getFilePath(SplFileInfo $file)
/**
* @param string $path
+ * @param int $mode
*
* @return RecursiveIteratorIterator
*/
- protected function getRecursiveDirectoryIterator($path)
+ protected function getRecursiveDirectoryIterator($path, $mode = RecursiveIteratorIterator::SELF_FIRST)
{
- $directory = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
- $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
-
- return $iterator;
+ return new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
+ $mode
+ );
}
/**
@@ -466,12 +515,14 @@ protected function mapFileInfo(SplFileInfo $file)
}
/**
- * @inheritdoc
+ * @param SplFileInfo $file
+ *
+ * @throws UnreadableFileException
*/
- public function applyPathPrefix($path)
+ protected function guardAgainstUnreadableFileInfo(SplFileInfo $file)
{
- $prefixedPath = parent::applyPathPrefix($path);
-
- return str_replace('/', DIRECTORY_SEPARATOR, $prefixedPath);
+ if ( ! $file->isReadable()) {
+ throw UnreadableFileException::forFileInfo($file);
+ }
}
}
diff --git a/application/vendor/league/flysystem/src/Adapter/NullAdapter.php b/application/vendor/league/flysystem/src/Adapter/NullAdapter.php
index e3f4904..2527087 100644
--- a/application/vendor/league/flysystem/src/Adapter/NullAdapter.php
+++ b/application/vendor/league/flysystem/src/Adapter/NullAdapter.php
@@ -29,7 +29,7 @@ public function has($path)
public function write($path, $contents, Config $config)
{
$type = 'file';
- $result = compact('contents', 'type', 'size', 'path');
+ $result = compact('contents', 'type', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
diff --git a/application/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php b/application/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php
index 64de443..fc0a747 100644
--- a/application/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php
+++ b/application/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php
@@ -15,7 +15,7 @@ trait NotSupportingVisibilityTrait
*/
public function getVisibility($path)
{
- throw new LogicException(get_class($this).' does not support visibility. Path: '.$path);
+ throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path);
}
/**
@@ -28,6 +28,6 @@ public function getVisibility($path)
*/
public function setVisibility($path, $visibility)
{
- throw new LogicException(get_class($this).' does not support visibility. Path: '.$path.', visibility: '.$visibility);
+ throw new LogicException(get_class($this) . ' does not support visibility. Path: ' . $path . ', visibility: ' . $visibility);
}
}
diff --git a/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php b/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php
index 44ed2e0..1b491a4 100644
--- a/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php
+++ b/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedCopyTrait.php
@@ -18,7 +18,7 @@ public function copy($path, $newpath)
{
$response = $this->readStream($path);
- if ($response === false || !is_resource($response['stream'])) {
+ if ($response === false || ! is_resource($response['stream'])) {
return false;
}
@@ -35,11 +35,17 @@ public function copy($path, $newpath)
/**
* @param string $path
+ *
+ * @return resource
*/
abstract public function readStream($path);
/**
- * @param string $path
+ * @param string $path
+ * @param resource $resource
+ * @param Config $config
+ *
+ * @return resource
*/
abstract public function writeStream($path, $resource, Config $config);
}
diff --git a/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php b/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php
index 3cd6ab4..2b31c01 100644
--- a/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php
+++ b/application/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php
@@ -2,22 +2,27 @@
namespace League\Flysystem\Adapter\Polyfill;
+/**
+ * A helper for adapters that only handle strings to provide read streams.
+ */
trait StreamedReadingTrait
{
/**
- * Get the contents of a file in a stream.
+ * Reads a file as a stream.
*
* @param string $path
*
- * @return resource|false false when not found, or a resource
+ * @return array|false
+ *
+ * @see League\Flysystem\ReadInterface::readStream()
*/
public function readStream($path)
{
- if (! $data = $this->read($path)) {
+ if ( ! $data = $this->read($path)) {
return false;
}
- $stream = tmpfile();
+ $stream = fopen('php://temp', 'w+b');
fwrite($stream, $data['contents']);
rewind($stream);
$data['stream'] = $stream;
@@ -26,12 +31,14 @@ public function readStream($path)
return $data;
}
- // Required abstract method
-
/**
+ * Reads a file.
+ *
* @param string $path
*
- * @return resource
+ * @return array|false
+ *
+ * @see League\Flysystem\ReadInterface::read()
*/
abstract public function read($path);
}
diff --git a/application/vendor/league/flysystem/src/Config.php b/application/vendor/league/flysystem/src/Config.php
index 00cf752..639f43d 100644
--- a/application/vendor/league/flysystem/src/Config.php
+++ b/application/vendor/league/flysystem/src/Config.php
@@ -10,7 +10,7 @@ class Config
protected $settings = [];
/**
- * @var Config
+ * @var Config|null
*/
protected $fallback;
@@ -34,7 +34,7 @@ public function __construct(array $settings = [])
*/
public function get($key, $default = null)
{
- if (! array_key_exists($key, $this->settings)) {
+ if ( ! array_key_exists($key, $this->settings)) {
return $this->getDefault($key, $default);
}
@@ -50,7 +50,13 @@ public function get($key, $default = null)
*/
public function has($key)
{
- return array_key_exists($key, $this->settings);
+ if (array_key_exists($key, $this->settings)) {
+ return true;
+ }
+
+ return $this->fallback instanceof Config
+ ? $this->fallback->has($key)
+ : false;
}
/**
@@ -63,7 +69,7 @@ public function has($key)
*/
protected function getDefault($key, $default)
{
- if (! $this->fallback) {
+ if ( ! $this->fallback) {
return $default;
}
diff --git a/application/vendor/league/flysystem/src/ConfigAwareTrait.php b/application/vendor/league/flysystem/src/ConfigAwareTrait.php
index 2476c6a..202d605 100644
--- a/application/vendor/league/flysystem/src/ConfigAwareTrait.php
+++ b/application/vendor/league/flysystem/src/ConfigAwareTrait.php
@@ -19,7 +19,7 @@ trait ConfigAwareTrait
*/
protected function setConfig($config)
{
- $this->config = $config ? Util::ensureConfig($config) : null;
+ $this->config = $config ? Util::ensureConfig($config) : new Config;
}
/**
@@ -29,10 +29,6 @@ protected function setConfig($config)
*/
public function getConfig()
{
- if ($this->config === null) {
- return $this->config = new Config;
- }
-
return $this->config;
}
diff --git a/application/vendor/league/flysystem/src/Directory.php b/application/vendor/league/flysystem/src/Directory.php
index 6ba744b..d4f90a8 100644
--- a/application/vendor/league/flysystem/src/Directory.php
+++ b/application/vendor/league/flysystem/src/Directory.php
@@ -2,6 +2,9 @@
namespace League\Flysystem;
+/**
+ * @deprecated
+ */
class Directory extends Handler
{
/**
diff --git a/application/vendor/league/flysystem/src/File.php b/application/vendor/league/flysystem/src/File.php
index 3294af5..4a4b7a0 100644
--- a/application/vendor/league/flysystem/src/File.php
+++ b/application/vendor/league/flysystem/src/File.php
@@ -2,6 +2,9 @@
namespace League\Flysystem;
+/**
+ * @deprecated
+ */
class File extends Handler
{
/**
@@ -17,7 +20,7 @@ public function exists()
/**
* Read the file.
*
- * @return string file contents
+ * @return string|false file contents
*/
public function read()
{
@@ -27,7 +30,7 @@ public function read()
/**
* Read the file as a stream.
*
- * @return resource file stream
+ * @return resource|false file stream
*/
public function readStream()
{
@@ -143,7 +146,7 @@ public function copy($newpath)
/**
* Get the file's timestamp.
*
- * @return int unix timestamp
+ * @return string|false The timestamp or false on failure.
*/
public function getTimestamp()
{
@@ -153,7 +156,7 @@ public function getTimestamp()
/**
* Get the file's mimetype.
*
- * @return string mimetime
+ * @return string|false The file mime-type or false on failure.
*/
public function getMimetype()
{
@@ -163,7 +166,7 @@ public function getMimetype()
/**
* Get the file's visibility.
*
- * @return string visibility
+ * @return string|false The visibility (public|private) or false on failure.
*/
public function getVisibility()
{
@@ -173,7 +176,7 @@ public function getVisibility()
/**
* Get the file's metadata.
*
- * @return array
+ * @return array|false The file metadata or false on failure.
*/
public function getMetadata()
{
@@ -183,7 +186,7 @@ public function getMetadata()
/**
* Get the file size.
*
- * @return int file size
+ * @return int|false The file size or false on failure.
*/
public function getSize()
{
diff --git a/application/vendor/league/flysystem/src/FileExistsException.php b/application/vendor/league/flysystem/src/FileExistsException.php
index c0b63da..c82e20c 100644
--- a/application/vendor/league/flysystem/src/FileExistsException.php
+++ b/application/vendor/league/flysystem/src/FileExistsException.php
@@ -22,11 +22,11 @@ public function __construct($path, $code = 0, BaseException $previous = null)
{
$this->path = $path;
- parent::__construct('File already exists at path: '.$this->getPath(), $code, $previous);
+ parent::__construct('File already exists at path: ' . $this->getPath(), $code, $previous);
}
/**
- * Get the path which was not found.
+ * Get the path which was found.
*
* @return string
*/
diff --git a/application/vendor/league/flysystem/src/FileNotFoundException.php b/application/vendor/league/flysystem/src/FileNotFoundException.php
index b66a4cc..989df69 100644
--- a/application/vendor/league/flysystem/src/FileNotFoundException.php
+++ b/application/vendor/league/flysystem/src/FileNotFoundException.php
@@ -22,7 +22,7 @@ public function __construct($path, $code = 0, BaseException $previous = null)
{
$this->path = $path;
- parent::__construct('File not found at path: '.$this->getPath(), $code, $previous);
+ parent::__construct('File not found at path: ' . $this->getPath(), $code, $previous);
}
/**
diff --git a/application/vendor/league/flysystem/src/Filesystem.php b/application/vendor/league/flysystem/src/Filesystem.php
index 84e204b..18b590e 100644
--- a/application/vendor/league/flysystem/src/Filesystem.php
+++ b/application/vendor/league/flysystem/src/Filesystem.php
@@ -3,11 +3,14 @@
namespace League\Flysystem;
use InvalidArgumentException;
+use League\Flysystem\Adapter\CanOverwriteFiles;
use League\Flysystem\Plugin\PluggableTrait;
use League\Flysystem\Util\ContentListingFormatter;
/**
* @method array getWithMetadata(string $path, array $metadata)
+ * @method bool forceCopy(string $path, string $newpath)
+ * @method bool forceRename(string $path, string $newpath)
* @method array listFiles(string $path = '', boolean $recursive = false)
* @method array listPaths(string $path = '', boolean $recursive = false)
* @method array listWith(array $keys = [], $directory = '', $recursive = false)
@@ -51,7 +54,7 @@ public function has($path)
{
$path = Util::normalizePath($path);
- return (bool) $this->getAdapter()->has($path);
+ return strlen($path) === 0 ? false : (bool) $this->getAdapter()->has($path);
}
/**
@@ -71,7 +74,7 @@ public function write($path, $contents, array $config = [])
*/
public function writeStream($path, $resource, array $config = [])
{
- if (! is_resource($resource)) {
+ if ( ! is_resource($resource)) {
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
}
@@ -92,7 +95,7 @@ public function put($path, $contents, array $config = [])
$path = Util::normalizePath($path);
$config = $this->prepareConfig($config);
- if ($this->has($path)) {
+ if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) {
return (bool) $this->getAdapter()->update($path, $contents, $config);
}
@@ -104,7 +107,7 @@ public function put($path, $contents, array $config = [])
*/
public function putStream($path, $resource, array $config = [])
{
- if (! is_resource($resource)) {
+ if ( ! is_resource($resource)) {
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
}
@@ -112,7 +115,7 @@ public function putStream($path, $resource, array $config = [])
$config = $this->prepareConfig($config);
Util::rewindStream($resource);
- if ($this->has($path)) {
+ if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) {
return (bool) $this->getAdapter()->updateStream($path, $resource, $config);
}
@@ -155,7 +158,7 @@ public function update($path, $contents, array $config = [])
*/
public function updateStream($path, $resource, array $config = [])
{
- if (! is_resource($resource)) {
+ if ( ! is_resource($resource)) {
throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.');
}
@@ -175,7 +178,7 @@ public function read($path)
$path = Util::normalizePath($path);
$this->assertPresent($path);
- if (! ($object = $this->getAdapter()->read($path))) {
+ if ( ! ($object = $this->getAdapter()->read($path))) {
return false;
}
@@ -190,7 +193,7 @@ public function readStream($path)
$path = Util::normalizePath($path);
$this->assertPresent($path);
- if (! $object = $this->getAdapter()->readStream($path)) {
+ if ( ! $object = $this->getAdapter()->readStream($path)) {
return false;
}
@@ -267,7 +270,8 @@ public function listContents($directory = '', $recursive = false)
$directory = Util::normalizePath($directory);
$contents = $this->getAdapter()->listContents($directory, $recursive);
- return (new ContentListingFormatter($directory, $recursive))->formatListing($contents);
+ return (new ContentListingFormatter($directory, $recursive, $this->config->get('case_sensitive', true)))
+ ->formatListing($contents);
}
/**
@@ -278,7 +282,7 @@ public function getMimetype($path)
$path = Util::normalizePath($path);
$this->assertPresent($path);
- if (! $object = $this->getAdapter()->getMimetype($path)) {
+ if (( ! $object = $this->getAdapter()->getMimetype($path)) || ! array_key_exists('mimetype', $object)) {
return false;
}
@@ -293,7 +297,7 @@ public function getTimestamp($path)
$path = Util::normalizePath($path);
$this->assertPresent($path);
- if (! $object = $this->getAdapter()->getTimestamp($path)) {
+ if (( ! $object = $this->getAdapter()->getTimestamp($path)) || ! array_key_exists('timestamp', $object)) {
return false;
}
@@ -308,7 +312,7 @@ public function getVisibility($path)
$path = Util::normalizePath($path);
$this->assertPresent($path);
- if (($object = $this->getAdapter()->getVisibility($path)) === false) {
+ if (( ! $object = $this->getAdapter()->getVisibility($path)) || ! array_key_exists('visibility', $object)) {
return false;
}
@@ -321,8 +325,9 @@ public function getVisibility($path)
public function getSize($path)
{
$path = Util::normalizePath($path);
+ $this->assertPresent($path);
- if (($object = $this->getAdapter()->getSize($path)) === false || !isset($object['size'])) {
+ if (( ! $object = $this->getAdapter()->getSize($path)) || ! array_key_exists('size', $object)) {
return false;
}
@@ -335,6 +340,7 @@ public function getSize($path)
public function setVisibility($path, $visibility)
{
$path = Util::normalizePath($path);
+ $this->assertPresent($path);
return (bool) $this->getAdapter()->setVisibility($path, $visibility);
}
@@ -357,7 +363,7 @@ public function get($path, Handler $handler = null)
{
$path = Util::normalizePath($path);
- if (! $handler) {
+ if ( ! $handler) {
$metadata = $this->getMetadata($path);
$handler = $metadata['type'] === 'file' ? new File($this, $path) : new Directory($this, $path);
}
@@ -374,10 +380,12 @@ public function get($path, Handler $handler = null)
* @param string $path path to file
*
* @throws FileNotFoundException
+ *
+ * @return void
*/
public function assertPresent($path)
{
- if (! $this->has($path)) {
+ if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
throw new FileNotFoundException($path);
}
}
@@ -388,10 +396,12 @@ public function assertPresent($path)
* @param string $path path to file
*
* @throws FileExistsException
+ *
+ * @return void
*/
public function assertAbsent($path)
{
- if ($this->has($path)) {
+ if ($this->config->get('disable_asserts', false) === false && $this->has($path)) {
throw new FileExistsException($path);
}
}
diff --git a/application/vendor/league/flysystem/src/FilesystemInterface.php b/application/vendor/league/flysystem/src/FilesystemInterface.php
index d631443..09b811b 100644
--- a/application/vendor/league/flysystem/src/FilesystemInterface.php
+++ b/application/vendor/league/flysystem/src/FilesystemInterface.php
@@ -2,6 +2,8 @@
namespace League\Flysystem;
+use InvalidArgumentException;
+
interface FilesystemInterface
{
/**
@@ -61,6 +63,8 @@ public function getMetadata($path);
*
* @param string $path The path to the file.
*
+ * @throws FileNotFoundException
+ *
* @return int|false The file size or false on failure.
*/
public function getSize($path);
@@ -216,6 +220,8 @@ public function createDir($dirname, array $config = []);
* @param string $path The path to the file.
* @param string $visibility One of 'public' or 'private'.
*
+ * @throws FileNotFoundException
+ *
* @return bool True on success, false on failure.
*/
public function setVisibility($path, $visibility);
@@ -258,6 +264,8 @@ public function readAndDelete($path);
/**
* Get a file/directory handler.
*
+ * @deprecated
+ *
* @param string $path The path to the file.
* @param Handler $handler An optional existing handler to populate.
*
diff --git a/application/vendor/league/flysystem/src/FilesystemNotFoundException.php b/application/vendor/league/flysystem/src/FilesystemNotFoundException.php
new file mode 100644
index 0000000..0c16aa0
--- /dev/null
+++ b/application/vendor/league/flysystem/src/FilesystemNotFoundException.php
@@ -0,0 +1,12 @@
+ Filesystem,]
+ *
+ * @throws InvalidArgumentException
*/
public function __construct(array $filesystems = [])
{
@@ -65,7 +45,9 @@ public function __construct(array $filesystems = [])
/**
* Mount filesystems.
*
- * @param array $filesystems [:prefix => Filesystem,]
+ * @param FilesystemInterface[] $filesystems [:prefix => Filesystem,]
+ *
+ * @throws InvalidArgumentException
*
* @return $this
*/
@@ -84,12 +66,14 @@ public function mountFilesystems(array $filesystems)
* @param string $prefix
* @param FilesystemInterface $filesystem
*
+ * @throws InvalidArgumentException
+ *
* @return $this
*/
public function mountFilesystem($prefix, FilesystemInterface $filesystem)
{
- if (! is_string($prefix)) {
- throw new InvalidArgumentException(__METHOD__.' expects argument #1 to be a string.');
+ if ( ! is_string($prefix)) {
+ throw new InvalidArgumentException(__METHOD__ . ' expects argument #1 to be a string.');
}
$this->filesystems[$prefix] = $filesystem;
@@ -102,14 +86,14 @@ public function mountFilesystem($prefix, FilesystemInterface $filesystem)
*
* @param string $prefix
*
- * @throws LogicException
+ * @throws FilesystemNotFoundException
*
* @return FilesystemInterface
*/
public function getFilesystem($prefix)
{
- if (! isset($this->filesystems[$prefix])) {
- throw new LogicException('No filesystem mounted with prefix '.$prefix);
+ if ( ! isset($this->filesystems[$prefix])) {
+ throw new FilesystemNotFoundException('No filesystem mounted with prefix ' . $prefix);
}
return $this->filesystems[$prefix];
@@ -120,25 +104,23 @@ public function getFilesystem($prefix)
*
* @param array $arguments
*
+ * @throws InvalidArgumentException
+ *
* @return array [:prefix, :arguments]
*/
public function filterPrefix(array $arguments)
{
if (empty($arguments)) {
- throw new LogicException('At least one argument needed');
+ throw new InvalidArgumentException('At least one argument needed');
}
$path = array_shift($arguments);
- if (! is_string($path)) {
+ if ( ! is_string($path)) {
throw new InvalidArgumentException('First argument should be a string');
}
- if (! preg_match('#^.+\:\/\/.*#', $path)) {
- throw new InvalidArgumentException('No prefix detected in path: '.$path);
- }
-
- list($prefix, $path) = explode('://', $path, 2);
+ list($prefix, $path) = $this->getPrefixAndPath($path);
array_unshift($arguments, $path);
return [$prefix, $arguments];
@@ -148,13 +130,15 @@ public function filterPrefix(array $arguments)
* @param string $directory
* @param bool $recursive
*
+ * @throws InvalidArgumentException
+ * @throws FilesystemNotFoundException
+ *
* @return array
*/
public function listContents($directory = '', $recursive = false)
{
- list($prefix, $arguments) = $this->filterPrefix([$directory]);
+ list($prefix, $directory) = $this->getPrefixAndPath($directory);
$filesystem = $this->getFilesystem($prefix);
- $directory = array_shift($arguments);
$result = $filesystem->listContents($directory, $recursive);
foreach ($result as &$file) {
@@ -170,6 +154,9 @@ public function listContents($directory = '', $recursive = false)
* @param string $method
* @param array $arguments
*
+ * @throws InvalidArgumentException
+ * @throws FilesystemNotFoundException
+ *
* @return mixed
*/
public function __call($method, $arguments)
@@ -180,26 +167,29 @@ public function __call($method, $arguments)
}
/**
- * @param $from
- * @param $to
+ * @param string $from
+ * @param string $to
+ * @param array $config
+ *
+ * @throws InvalidArgumentException
+ * @throws FilesystemNotFoundException
+ * @throws FileExistsException
*
* @return bool
*/
- public function copy($from, $to)
+ public function copy($from, $to, array $config = [])
{
- list($prefixFrom, $arguments) = $this->filterPrefix([$from]);
+ list($prefixFrom, $from) = $this->getPrefixAndPath($from);
- $fsFrom = $this->getFilesystem($prefixFrom);
- $buffer = call_user_func_array([$fsFrom, 'readStream'], $arguments);
+ $buffer = $this->getFilesystem($prefixFrom)->readStream($from);
if ($buffer === false) {
return false;
}
- list($prefixTo, $arguments) = $this->filterPrefix([$to]);
+ list($prefixTo, $to) = $this->getPrefixAndPath($to);
- $fsTo = $this->getFilesystem($prefixTo);
- $result = call_user_func_array([$fsTo, 'writeStream'], array_merge($arguments, [$buffer]));
+ $result = $this->getFilesystem($prefixTo)->writeStream($to, $buffer, $config);
if (is_resource($buffer)) {
fclose($buffer);
@@ -214,11 +204,15 @@ public function copy($from, $to)
* @param array $keys
* @param string $directory
* @param bool $recursive
+ *
+ * @throws InvalidArgumentException
+ * @throws FilesystemNotFoundException
+ *
+ * @return array
*/
public function listWith(array $keys = [], $directory = '', $recursive = false)
{
- list($prefix, $arguments) = $this->filterPrefix([$directory]);
- $directory = $arguments[0];
+ list($prefix, $directory) = $this->getPrefixAndPath($directory);
$arguments = [$keys, $directory, $recursive];
return $this->invokePluginOnFilesystem('listWith', $arguments, $prefix);
@@ -227,14 +221,32 @@ public function listWith(array $keys = [], $directory = '', $recursive = false)
/**
* Move a file.
*
- * @param $from
- * @param $to
+ * @param string $from
+ * @param string $to
+ * @param array $config
+ *
+ * @throws InvalidArgumentException
+ * @throws FilesystemNotFoundException
*
* @return bool
*/
- public function move($from, $to)
+ public function move($from, $to, array $config = [])
{
- $copied = $this->copy($from, $to);
+ list($prefixFrom, $pathFrom) = $this->getPrefixAndPath($from);
+ list($prefixTo, $pathTo) = $this->getPrefixAndPath($to);
+
+ if ($prefixFrom === $prefixTo) {
+ $filesystem = $this->getFilesystem($prefixFrom);
+ $renamed = $filesystem->rename($pathFrom, $pathTo);
+
+ if ($renamed && isset($config['visibility'])) {
+ return $filesystem->setVisibility($pathTo, $config['visibility']);
+ }
+
+ return $renamed;
+ }
+
+ $copied = $this->copy($from, $to, $config);
if ($copied) {
return $this->delete($from);
@@ -246,9 +258,11 @@ public function move($from, $to)
/**
* Invoke a plugin on a filesystem mounted on a given prefix.
*
- * @param $method
- * @param $arguments
- * @param $prefix
+ * @param string $method
+ * @param array $arguments
+ * @param string $prefix
+ *
+ * @throws FilesystemNotFoundException
*
* @return mixed
*/
@@ -266,4 +280,369 @@ public function invokePluginOnFilesystem($method, $arguments, $prefix)
return call_user_func_array($callback, $arguments);
}
+
+ /**
+ * @param string $path
+ *
+ * @throws InvalidArgumentException
+ *
+ * @return string[] [:prefix, :path]
+ */
+ protected function getPrefixAndPath($path)
+ {
+ if (strpos($path, '://') < 1) {
+ throw new InvalidArgumentException('No prefix detected in path: ' . $path);
+ }
+
+ return explode('://', $path, 2);
+ }
+
+ /**
+ * Check whether a file exists.
+ *
+ * @param string $path
+ *
+ * @return bool
+ */
+ public function has($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->has($path);
+ }
+
+ /**
+ * Read a file.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return string|false The file contents or false on failure.
+ */
+ public function read($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->read($path);
+ }
+
+ /**
+ * Retrieves a read-stream for a path.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return resource|false The path resource or false on failure.
+ */
+ public function readStream($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->readStream($path);
+ }
+
+ /**
+ * Get a file's metadata.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return array|false The file metadata or false on failure.
+ */
+ public function getMetadata($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->getMetadata($path);
+ }
+
+ /**
+ * Get a file's size.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return int|false The file size or false on failure.
+ */
+ public function getSize($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->getSize($path);
+ }
+
+ /**
+ * Get a file's mime-type.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return string|false The file mime-type or false on failure.
+ */
+ public function getMimetype($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->getMimetype($path);
+ }
+
+ /**
+ * Get a file's timestamp.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return string|false The timestamp or false on failure.
+ */
+ public function getTimestamp($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->getTimestamp($path);
+ }
+
+ /**
+ * Get a file's visibility.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return string|false The visibility (public|private) or false on failure.
+ */
+ public function getVisibility($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->getVisibility($path);
+ }
+
+ /**
+ * Write a new file.
+ *
+ * @param string $path The path of the new file.
+ * @param string $contents The file contents.
+ * @param array $config An optional configuration array.
+ *
+ * @throws FileExistsException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function write($path, $contents, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->write($path, $contents, $config);
+ }
+
+ /**
+ * Write a new file using a stream.
+ *
+ * @param string $path The path of the new file.
+ * @param resource $resource The file handle.
+ * @param array $config An optional configuration array.
+ *
+ * @throws InvalidArgumentException If $resource is not a file handle.
+ * @throws FileExistsException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function writeStream($path, $resource, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->writeStream($path, $resource, $config);
+ }
+
+ /**
+ * Update an existing file.
+ *
+ * @param string $path The path of the existing file.
+ * @param string $contents The file contents.
+ * @param array $config An optional configuration array.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function update($path, $contents, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->update($path, $contents, $config);
+ }
+
+ /**
+ * Update an existing file using a stream.
+ *
+ * @param string $path The path of the existing file.
+ * @param resource $resource The file handle.
+ * @param array $config An optional configuration array.
+ *
+ * @throws InvalidArgumentException If $resource is not a file handle.
+ * @throws FileNotFoundException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function updateStream($path, $resource, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->updateStream($path, $resource, $config);
+ }
+
+ /**
+ * Rename a file.
+ *
+ * @param string $path Path to the existing file.
+ * @param string $newpath The new path of the file.
+ *
+ * @throws FileExistsException Thrown if $newpath exists.
+ * @throws FileNotFoundException Thrown if $path does not exist.
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function rename($path, $newpath)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->rename($path, $newpath);
+ }
+
+ /**
+ * Delete a file.
+ *
+ * @param string $path
+ *
+ * @throws FileNotFoundException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function delete($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->delete($path);
+ }
+
+ /**
+ * Delete a directory.
+ *
+ * @param string $dirname
+ *
+ * @throws RootViolationException Thrown if $dirname is empty.
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function deleteDir($dirname)
+ {
+ list($prefix, $dirname) = $this->getPrefixAndPath($dirname);
+
+ return $this->getFilesystem($prefix)->deleteDir($dirname);
+ }
+
+ /**
+ * Create a directory.
+ *
+ * @param string $dirname The name of the new directory.
+ * @param array $config An optional configuration array.
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function createDir($dirname, array $config = [])
+ {
+ list($prefix, $dirname) = $this->getPrefixAndPath($dirname);
+
+ return $this->getFilesystem($prefix)->createDir($dirname);
+ }
+
+ /**
+ * Set the visibility for a file.
+ *
+ * @param string $path The path to the file.
+ * @param string $visibility One of 'public' or 'private'.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function setVisibility($path, $visibility)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->setVisibility($path, $visibility);
+ }
+
+ /**
+ * Create a file or update if exists.
+ *
+ * @param string $path The path to the file.
+ * @param string $contents The file contents.
+ * @param array $config An optional configuration array.
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function put($path, $contents, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->put($path, $contents, $config);
+ }
+
+ /**
+ * Create a file or update if exists.
+ *
+ * @param string $path The path to the file.
+ * @param resource $resource The file handle.
+ * @param array $config An optional configuration array.
+ *
+ * @throws InvalidArgumentException Thrown if $resource is not a resource.
+ *
+ * @return bool True on success, false on failure.
+ */
+ public function putStream($path, $resource, array $config = [])
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->putStream($path, $resource, $config);
+ }
+
+ /**
+ * Read and delete a file.
+ *
+ * @param string $path The path to the file.
+ *
+ * @throws FileNotFoundException
+ *
+ * @return string|false The file contents, or false on failure.
+ */
+ public function readAndDelete($path)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->readAndDelete($path);
+ }
+
+ /**
+ * Get a file/directory handler.
+ *
+ * @deprecated
+ *
+ * @param string $path The path to the file.
+ * @param Handler $handler An optional existing handler to populate.
+ *
+ * @return Handler Either a file or directory handler.
+ */
+ public function get($path, Handler $handler = null)
+ {
+ list($prefix, $path) = $this->getPrefixAndPath($path);
+
+ return $this->getFilesystem($prefix)->get($path);
+ }
}
diff --git a/application/vendor/league/flysystem/src/NotSupportedException.php b/application/vendor/league/flysystem/src/NotSupportedException.php
index 5d20839..08f47f7 100644
--- a/application/vendor/league/flysystem/src/NotSupportedException.php
+++ b/application/vendor/league/flysystem/src/NotSupportedException.php
@@ -18,7 +18,7 @@ public static function forLink(SplFileInfo $file)
{
$message = 'Links are not supported, encountered link at ';
- return new static($message.$file->getPathname());
+ return new static($message . $file->getPathname());
}
/**
diff --git a/application/vendor/league/flysystem/src/Plugin/EmptyDir.php b/application/vendor/league/flysystem/src/Plugin/EmptyDir.php
index 9502333..b5ae7f5 100644
--- a/application/vendor/league/flysystem/src/Plugin/EmptyDir.php
+++ b/application/vendor/league/flysystem/src/Plugin/EmptyDir.php
@@ -17,7 +17,7 @@ public function getMethod()
/**
* Empty a directory's contents.
*
- * @param $dirname
+ * @param string $dirname
*/
public function handle($dirname)
{
diff --git a/application/vendor/league/flysystem/src/Plugin/ForcedCopy.php b/application/vendor/league/flysystem/src/Plugin/ForcedCopy.php
new file mode 100644
index 0000000..a41e9f3
--- /dev/null
+++ b/application/vendor/league/flysystem/src/Plugin/ForcedCopy.php
@@ -0,0 +1,44 @@
+filesystem->delete($newpath);
+ } catch (FileNotFoundException $e) {
+ // The destination path does not exist. That's ok.
+ $deleted = true;
+ }
+
+ if ($deleted) {
+ return $this->filesystem->copy($path, $newpath);
+ }
+
+ return false;
+ }
+}
diff --git a/application/vendor/league/flysystem/src/Plugin/ForcedRename.php b/application/vendor/league/flysystem/src/Plugin/ForcedRename.php
new file mode 100644
index 0000000..3f51cd6
--- /dev/null
+++ b/application/vendor/league/flysystem/src/Plugin/ForcedRename.php
@@ -0,0 +1,44 @@
+filesystem->delete($newpath);
+ } catch (FileNotFoundException $e) {
+ // The destination path does not exist. That's ok.
+ $deleted = true;
+ }
+
+ if ($deleted) {
+ return $this->filesystem->rename($path, $newpath);
+ }
+
+ return false;
+ }
+}
diff --git a/application/vendor/league/flysystem/src/Plugin/GetWithMetadata.php b/application/vendor/league/flysystem/src/Plugin/GetWithMetadata.php
index b88fd68..6fe4f05 100644
--- a/application/vendor/league/flysystem/src/Plugin/GetWithMetadata.php
+++ b/application/vendor/league/flysystem/src/Plugin/GetWithMetadata.php
@@ -3,6 +3,7 @@
namespace League\Flysystem\Plugin;
use InvalidArgumentException;
+use League\Flysystem\FileNotFoundException;
class GetWithMetadata extends AbstractPlugin
{
@@ -23,22 +24,23 @@ public function getMethod()
* @param array $metadata metadata keys
*
* @throws InvalidArgumentException
+ * @throws FileNotFoundException
*
- * @return array metadata
+ * @return array|false metadata
*/
public function handle($path, array $metadata)
{
$object = $this->filesystem->getMetadata($path);
- if (! $object) {
+ if ( ! $object) {
return false;
}
$keys = array_diff($metadata, array_keys($object));
foreach ($keys as $key) {
- if (! method_exists($this->filesystem, $method = 'get'.ucfirst($key))) {
- throw new InvalidArgumentException('Could not fetch metadata: '.$key);
+ if ( ! method_exists($this->filesystem, $method = 'get' . ucfirst($key))) {
+ throw new InvalidArgumentException('Could not fetch metadata: ' . $key);
}
$object[$key] = $this->filesystem->{$method}($path);
diff --git a/application/vendor/league/flysystem/src/Plugin/ListWith.php b/application/vendor/league/flysystem/src/Plugin/ListWith.php
index 341a219..d90464e 100644
--- a/application/vendor/league/flysystem/src/Plugin/ListWith.php
+++ b/application/vendor/league/flysystem/src/Plugin/ListWith.php
@@ -40,17 +40,17 @@ public function handle(array $keys = [], $directory = '', $recursive = false)
/**
* Get a meta-data value by key name.
*
- * @param array $object
- * @param $key
+ * @param array $object
+ * @param string $key
*
* @return array
*/
protected function getMetadataByName(array $object, $key)
{
- $method = 'get'.ucfirst($key);
+ $method = 'get' . ucfirst($key);
- if (! method_exists($this->filesystem, $method)) {
- throw new \InvalidArgumentException('Could not get meta-data for key: '.$key);
+ if ( ! method_exists($this->filesystem, $method)) {
+ throw new \InvalidArgumentException('Could not get meta-data for key: ' . $key);
}
$object[$key] = $this->filesystem->{$method}($object['path']);
diff --git a/application/vendor/league/flysystem/src/Plugin/PluggableTrait.php b/application/vendor/league/flysystem/src/Plugin/PluggableTrait.php
index 4f39a16..922edfe 100644
--- a/application/vendor/league/flysystem/src/Plugin/PluggableTrait.php
+++ b/application/vendor/league/flysystem/src/Plugin/PluggableTrait.php
@@ -19,10 +19,16 @@ trait PluggableTrait
*
* @param PluginInterface $plugin
*
+ * @throws LogicException
+ *
* @return $this
*/
public function addPlugin(PluginInterface $plugin)
{
+ if ( ! method_exists($plugin, 'handle')) {
+ throw new LogicException(get_class($plugin) . ' does not have a handle method.');
+ }
+
$this->plugins[$plugin->getMethod()] = $plugin;
return $this;
@@ -33,18 +39,14 @@ public function addPlugin(PluginInterface $plugin)
*
* @param string $method
*
- * @throws LogicException
+ * @throws PluginNotFoundException
*
- * @return PluginInterface $plugin
+ * @return PluginInterface
*/
protected function findPlugin($method)
{
- if (! isset($this->plugins[$method])) {
- throw new PluginNotFoundException('Plugin not found for method: '.$method);
- }
-
- if (! method_exists($this->plugins[$method], 'handle')) {
- throw new LogicException(get_class($this->plugins[$method]).' does not have a handle method.');
+ if ( ! isset($this->plugins[$method])) {
+ throw new PluginNotFoundException('Plugin not found for method: ' . $method);
}
return $this->plugins[$method];
@@ -53,8 +55,11 @@ protected function findPlugin($method)
/**
* Invoke a plugin by method name.
*
- * @param string $method
- * @param array $arguments
+ * @param string $method
+ * @param array $arguments
+ * @param FilesystemInterface $filesystem
+ *
+ * @throws PluginNotFoundException
*
* @return mixed
*/
@@ -84,8 +89,8 @@ public function __call($method, array $arguments)
} catch (PluginNotFoundException $e) {
throw new BadMethodCallException(
'Call to undefined method '
- .get_class($this)
- .'::'.$method
+ . get_class($this)
+ . '::' . $method
);
}
}
diff --git a/application/vendor/league/flysystem/src/ReadInterface.php b/application/vendor/league/flysystem/src/ReadInterface.php
index f37e0c9..898a8d5 100644
--- a/application/vendor/league/flysystem/src/ReadInterface.php
+++ b/application/vendor/league/flysystem/src/ReadInterface.php
@@ -51,7 +51,7 @@ public function listContents($directory = '', $recursive = false);
public function getMetadata($path);
/**
- * Get all the meta data of a file or directory.
+ * Get the size of a file.
*
* @param string $path
*
@@ -69,7 +69,7 @@ public function getSize($path);
public function getMimetype($path);
/**
- * Get the timestamp of a file.
+ * Get the last modified time of a file as a timestamp.
*
* @param string $path
*
diff --git a/application/vendor/league/flysystem/src/SafeStorage.php b/application/vendor/league/flysystem/src/SafeStorage.php
new file mode 100644
index 0000000..5397f58
--- /dev/null
+++ b/application/vendor/league/flysystem/src/SafeStorage.php
@@ -0,0 +1,39 @@
+hash = spl_object_hash($this);
+ static::$safeStorage[$this->hash] = [];
+ }
+
+ public function storeSafely($key, $value)
+ {
+ static::$safeStorage[$this->hash][$key] = $value;
+ }
+
+ public function retrieveSafely($key)
+ {
+ if (array_key_exists($key, static::$safeStorage[$this->hash])) {
+ return static::$safeStorage[$this->hash][$key];
+ }
+ }
+
+ public function __destruct()
+ {
+ unset(static::$safeStorage[$this->hash]);
+ }
+}
diff --git a/application/vendor/league/flysystem/src/UnreadableFileException.php b/application/vendor/league/flysystem/src/UnreadableFileException.php
new file mode 100644
index 0000000..e668033
--- /dev/null
+++ b/application/vendor/league/flysystem/src/UnreadableFileException.php
@@ -0,0 +1,18 @@
+getRealPath()
+ )
+ );
+ }
+}
diff --git a/application/vendor/league/flysystem/src/Util.php b/application/vendor/league/flysystem/src/Util.php
index 5734856..2c77540 100644
--- a/application/vendor/league/flysystem/src/Util.php
+++ b/application/vendor/league/flysystem/src/Util.php
@@ -16,12 +16,17 @@ class Util
*/
public static function pathinfo($path)
{
- $pathinfo = pathinfo($path) + compact('path');
- $pathinfo['dirname'] = array_key_exists('dirname', $pathinfo)
- ? static::normalizeDirname($pathinfo['dirname'])
- : '';
+ $pathinfo = compact('path');
- return $pathinfo;
+ if ('' !== $dirname = dirname($path)) {
+ $pathinfo['dirname'] = static::normalizeDirname($dirname);
+ }
+
+ $pathinfo['basename'] = static::basename($path);
+
+ $pathinfo += pathinfo($pathinfo['basename']);
+
+ return $pathinfo + ['dirname' => ''];
}
/**
@@ -33,11 +38,7 @@ public static function pathinfo($path)
*/
public static function normalizeDirname($dirname)
{
- if ($dirname === '.') {
- return '';
- }
-
- return $dirname;
+ return $dirname === '.' ? '' : $dirname;
}
/**
@@ -65,7 +66,7 @@ public static function map(array $object, array $map)
$result = [];
foreach ($map as $from => $to) {
- if (! isset($object[$from])) {
+ if ( ! isset($object[$from])) {
continue;
}
@@ -86,20 +87,7 @@ public static function map(array $object, array $map)
*/
public static function normalizePath($path)
{
- // Remove any kind of funky unicode whitespace
- $normalized = preg_replace('#\p{C}+|^\./#u', '', $path);
- $normalized = static::normalizeRelativePath($normalized);
-
- if (preg_match('#/\.{2}|^\.{2}/|^\.{2}$#', $normalized)) {
- throw new LogicException(
- 'Path is outside of the defined root, path: [' . $path . '], resolved: [' . $normalized . ']'
- );
- }
-
- $normalized = preg_replace('#\\\{2,}#', '\\', trim($normalized, '\\'));
- $normalized = preg_replace('#/{2,}#', '/', trim($normalized, '/'));
-
- return $normalized;
+ return static::normalizeRelativePath($path);
}
/**
@@ -107,18 +95,54 @@ public static function normalizePath($path)
*
* @param string $path
*
+ * @throws LogicException
+ *
* @return string
*/
public static function normalizeRelativePath($path)
{
- // Path remove self referring paths ("/./").
- $path = preg_replace('#/\.(?=/)|^\./|/\./?$#', '', $path);
+ $path = str_replace('\\', '/', $path);
+ $path = static::removeFunkyWhiteSpace($path);
+
+ $parts = [];
+
+ foreach (explode('/', $path) as $part) {
+ switch ($part) {
+ case '':
+ case '.':
+ break;
+
+ case '..':
+ if (empty($parts)) {
+ throw new LogicException(
+ 'Path is outside of the defined root, path: [' . $path . ']'
+ );
+ }
+ array_pop($parts);
+ break;
+
+ default:
+ $parts[] = $part;
+ break;
+ }
+ }
- // Regex for resolving relative paths
- $regex = '#/*[^/\.]+/\.\.#Uu';
+ return implode('/', $parts);
+ }
- while (preg_match($regex, $path)) {
- $path = preg_replace($regex, '', $path);
+ /**
+ * Removes unprintable characters and invalid unicode characters.
+ *
+ * @param string $path
+ *
+ * @return string $path
+ */
+ protected static function removeFunkyWhiteSpace($path)
+ {
+ // We do this check in a loop, since removing invalid unicode characters
+ // can lead to new characters being created.
+ while (preg_match('#\p{C}+|^\./#u', $path)) {
+ $path = preg_replace('#\p{C}+|^\./#u', '', $path);
}
return $path;
@@ -152,8 +176,8 @@ public static function contentSize($contents)
/**
* Guess MIME Type based on the path of the file and it's content.
*
- * @param string $path
- * @param string $content
+ * @param string $path
+ * @param string|resource $content
*
* @return string|null MIME Type or NULL if no extension detected
*/
@@ -161,15 +185,11 @@ public static function guessMimeType($path, $content)
{
$mimeType = MimeType::detectByContent($content);
- if (empty($mimeType) || $mimeType === 'text/plain') {
- $extension = pathinfo($path, PATHINFO_EXTENSION);
-
- if ($extension) {
- $mimeType = MimeType::detectByFileExtension($extension) ?: 'text/plain';
- }
+ if ( ! (empty($mimeType) || in_array($mimeType, ['application/x-empty', 'text/plain', 'text/x-asm']))) {
+ return $mimeType;
}
- return $mimeType;
+ return MimeType::detectByFilename($path);
}
/**
@@ -185,11 +205,7 @@ public static function emulateDirectories(array $listing)
$listedDirectories = [];
foreach ($listing as $object) {
- list($directories, $listedDirectories) = static::emulateObjectDirectories(
- $object,
- $directories,
- $listedDirectories
- );
+ list($directories, $listedDirectories) = static::emulateObjectDirectories($object, $directories, $listedDirectories);
}
$directories = array_diff(array_unique($directories), array_unique($listedDirectories));
@@ -281,7 +297,7 @@ protected static function emulateObjectDirectories(array $object, array $directo
$parent = $object['dirname'];
- while (! empty($parent) && ! in_array($parent, $directories)) {
+ while ( ! empty($parent) && ! in_array($parent, $directories)) {
$directories[] = $parent;
$parent = static::dirname($parent);
}
@@ -294,4 +310,40 @@ protected static function emulateObjectDirectories(array $object, array $directo
return [$directories, $listedDirectories];
}
+
+ /**
+ * Returns the trailing name component of the path.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ private static function basename($path)
+ {
+ $separators = DIRECTORY_SEPARATOR === '/' ? '/' : '\/';
+
+ $path = rtrim($path, $separators);
+
+ $basename = preg_replace('#.*?([^' . preg_quote($separators, '#') . ']+$)#', '$1', $path);
+
+ if (DIRECTORY_SEPARATOR === '/') {
+ return $basename;
+ }
+ // @codeCoverageIgnoreStart
+ // Extra Windows path munging. This is tested via AppVeyor, but code
+ // coverage is not reported.
+
+ // Handle relative paths with drive letters. c:file.txt.
+ while (preg_match('#^[a-zA-Z]{1}:[^\\\/]#', $basename)) {
+ $basename = substr($basename, 2);
+ }
+
+ // Remove colon for standalone drive letter names.
+ if (preg_match('#^[a-zA-Z]{1}:$#', $basename)) {
+ $basename = rtrim($basename, ':');
+ }
+
+ return $basename;
+ // @codeCoverageIgnoreEnd
+ }
}
diff --git a/application/vendor/league/flysystem/src/Util/ContentListingFormatter.php b/application/vendor/league/flysystem/src/Util/ContentListingFormatter.php
index db453c4..ae0d3b9 100644
--- a/application/vendor/league/flysystem/src/Util/ContentListingFormatter.php
+++ b/application/vendor/league/flysystem/src/Util/ContentListingFormatter.php
@@ -13,19 +13,26 @@ class ContentListingFormatter
* @var string
*/
private $directory;
+
/**
* @var bool
*/
private $recursive;
+ /**
+ * @var bool
+ */
+ private $caseSensitive;
+
/**
* @param string $directory
* @param bool $recursive
*/
- public function __construct($directory, $recursive)
+ public function __construct($directory, $recursive, $caseSensitive = true)
{
- $this->directory = $directory;
+ $this->directory = rtrim($directory, '/');
$this->recursive = $recursive;
+ $this->caseSensitive = $caseSensitive;
}
/**
@@ -37,14 +44,9 @@ public function __construct($directory, $recursive)
*/
public function formatListing(array $listing)
{
- $listing = array_values(
- array_map(
- [$this, 'addPathInfo'],
- array_filter($listing, [$this, 'isEntryOutOfScope'])
- )
- );
-
- return $this->sortListing($listing);
+ $listing = array_filter(array_map([$this, 'addPathInfo'], $listing), [$this, 'isEntryOutOfScope']);
+
+ return $this->sortListing(array_values($listing));
}
private function addPathInfo(array $entry)
@@ -75,7 +77,7 @@ private function isEntryOutOfScope(array $entry)
/**
* Check if the entry resides within the parent directory.
*
- * @param $entry
+ * @param array $entry
*
* @return bool
*/
@@ -85,19 +87,23 @@ private function residesInDirectory(array $entry)
return true;
}
- return strpos($entry['path'], $this->directory . '/') === 0;
+ return $this->caseSensitive
+ ? strpos($entry['path'], $this->directory . '/') === 0
+ : stripos($entry['path'], $this->directory . '/') === 0;
}
/**
* Check if the entry is a direct child of the directory.
*
- * @param $entry
+ * @param array $entry
*
* @return bool
*/
private function isDirectChild(array $entry)
{
- return Util::dirname($entry['path']) === $this->directory;
+ return $this->caseSensitive
+ ? $entry['dirname'] === $this->directory
+ : strcasecmp($this->directory, $entry['dirname']) === 0;
}
/**
@@ -107,12 +113,9 @@ private function isDirectChild(array $entry)
*/
private function sortListing(array $listing)
{
- usort(
- $listing,
- function ($a, $b) {
- return strcasecmp($a['path'], $b['path']);
- }
- );
+ usort($listing, function ($a, $b) {
+ return strcasecmp($a['path'], $b['path']);
+ });
return $listing;
}
diff --git a/application/vendor/league/flysystem/src/Util/MimeType.php b/application/vendor/league/flysystem/src/Util/MimeType.php
index d44d013..a4bd5e2 100644
--- a/application/vendor/league/flysystem/src/Util/MimeType.php
+++ b/application/vendor/league/flysystem/src/Util/MimeType.php
@@ -2,31 +2,212 @@
namespace League\Flysystem\Util;
-use Finfo;
+use ErrorException;
+use finfo;
/**
* @internal
*/
class MimeType
{
+ protected static $extensionToMimeTypeMap = [
+ 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'csv' => 'text/csv',
+ 'bin' => 'application/octet-stream',
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'class' => 'application/octet-stream',
+ 'psd' => 'application/x-photoshop',
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/pdf',
+ 'eps' => 'application/postscript',
+ 'epub' => 'application/epub+zip',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'xlt' => 'application/vnd.ms-excel',
+ 'xla' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/powerpoint',
+ 'pot' => 'application/vnd.ms-powerpoint',
+ 'pps' => 'application/vnd.ms-powerpoint',
+ 'ppa' => 'application/vnd.ms-powerpoint',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
+ 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
+ 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
+ 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
+ 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
+ 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
+ 'wbxml' => 'application/wbxml',
+ 'wmlc' => 'application/wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'gz' => 'application/x-gzip',
+ 'gzip' => 'application/x-gzip',
+ 'php' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => 'application/javascript',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'z' => 'application/x-compress',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'rdf' => 'application/rdf+xml',
+ 'zip' => 'application/x-zip',
+ 'rar' => 'application/x-rar',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'aif' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => 'audio/x-wav',
+ 'jpg' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'gif' => 'image/gif',
+ 'bmp' => 'image/bmp',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'svg' => 'image/svg+xml',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
+ 'shtml' => 'text/html',
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => 'application/xml',
+ 'xsl' => 'application/xml',
+ 'dmn' => 'application/octet-stream',
+ 'bpmn' => 'application/octet-stream',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => 'video/x-msvideo',
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => 'application/msword',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'docm' => 'application/vnd.ms-word.template.macroEnabled.12',
+ 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
+ 'dot' => 'application/msword',
+ 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
+ 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
+ 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
+ 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
+ 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
+ 'word' => 'application/msword',
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822',
+ 'json' => 'application/json',
+ 'pem' => 'application/x-x509-user-cert',
+ 'p10' => 'application/x-pkcs10',
+ 'p12' => 'application/x-pkcs12',
+ 'p7a' => 'application/x-pkcs7-signature',
+ 'p7c' => 'application/pkcs7-mime',
+ 'p7m' => 'application/pkcs7-mime',
+ 'p7r' => 'application/x-pkcs7-certreqresp',
+ 'p7s' => 'application/pkcs7-signature',
+ 'crt' => 'application/x-x509-ca-cert',
+ 'crl' => 'application/pkix-crl',
+ 'der' => 'application/x-x509-ca-cert',
+ 'kdb' => 'application/octet-stream',
+ 'pgp' => 'application/pgp',
+ 'gpg' => 'application/gpg-keys',
+ 'sst' => 'application/octet-stream',
+ 'csr' => 'application/octet-stream',
+ 'rsa' => 'application/x-pkcs7',
+ 'cer' => 'application/pkix-cert',
+ '3g2' => 'video/3gpp2',
+ '3gp' => 'video/3gp',
+ 'mp4' => 'video/mp4',
+ 'm4a' => 'audio/x-m4a',
+ 'f4v' => 'video/mp4',
+ 'webm' => 'video/webm',
+ 'aac' => 'audio/x-acc',
+ 'm4u' => 'application/vnd.mpegurl',
+ 'm3u' => 'text/plain',
+ 'xspf' => 'application/xspf+xml',
+ 'vlc' => 'application/videolan',
+ 'wmv' => 'video/x-ms-wmv',
+ 'au' => 'audio/x-au',
+ 'ac3' => 'audio/ac3',
+ 'flac' => 'audio/x-flac',
+ 'ogg' => 'audio/ogg',
+ 'kmz' => 'application/vnd.google-earth.kmz',
+ 'kml' => 'application/vnd.google-earth.kml+xml',
+ 'ics' => 'text/calendar',
+ 'zsh' => 'text/x-scriptzsh',
+ '7zip' => 'application/x-7z-compressed',
+ 'cdr' => 'application/cdr',
+ 'wma' => 'audio/x-ms-wma',
+ 'jar' => 'application/java-archive',
+ 'tex' => 'application/x-tex',
+ 'latex' => 'application/x-latex',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
+ 'odc' => 'application/vnd.oasis.opendocument.chart',
+ 'odf' => 'application/vnd.oasis.opendocument.formula',
+ 'odi' => 'application/vnd.oasis.opendocument.image',
+ 'odm' => 'application/vnd.oasis.opendocument.text-master',
+ 'odb' => 'application/vnd.oasis.opendocument.database',
+ 'ott' => 'application/vnd.oasis.opendocument.text-template',
+ ];
+
/**
* Detects MIME Type based on given content.
*
- * @param string $content
+ * @param mixed $content
*
* @return string|null MIME Type or NULL if no mime type detected
*/
public static function detectByContent($content)
{
- if (! class_exists('Finfo')) {
- return;
+ if ( ! class_exists('finfo') || ! is_string($content)) {
+ return null;
}
+ try {
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
- $finfo = new Finfo(FILEINFO_MIME_TYPE);
- $mimeType = $finfo->buffer($content);
-
- return $mimeType ?: null;
- }
+ return $finfo->buffer($content) ?: null;
+ // @codeCoverageIgnoreStart
+ } catch (ErrorException $e) {
+ // This is caused by an array to string conversion error.
+ }
+ } // @codeCoverageIgnoreEnd
/**
* Detects MIME Type based on file extension.
@@ -37,15 +218,21 @@ public static function detectByContent($content)
*/
public static function detectByFileExtension($extension)
{
- static $extensionToMimeTypeMap;
+ return isset(static::$extensionToMimeTypeMap[$extension])
+ ? static::$extensionToMimeTypeMap[$extension]
+ : 'text/plain';
+ }
- if (! $extensionToMimeTypeMap) {
- $extensionToMimeTypeMap = static::getExtensionToMimeTypeMap();
- }
+ /**
+ * @param string $filename
+ *
+ * @return string|null MIME Type or NULL if no extension detected
+ */
+ public static function detectByFilename($filename)
+ {
+ $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
- if (isset($extensionToMimeTypeMap[$extension])) {
- return $extensionToMimeTypeMap[$extension];
- }
+ return empty($extension) ? 'text/plain' : static::detectByFileExtension($extension);
}
/**
@@ -53,146 +240,6 @@ public static function detectByFileExtension($extension)
*/
public static function getExtensionToMimeTypeMap()
{
- return [
- 'hqx' => 'application/mac-binhex40',
- 'cpt' => 'application/mac-compactpro',
- 'csv' => 'text/x-comma-separated-values',
- 'bin' => 'application/octet-stream',
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => 'application/octet-stream',
- 'class' => 'application/octet-stream',
- 'psd' => 'application/x-photoshop',
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => 'application/pdf',
- 'ai' => 'application/pdf',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => 'application/vnd.ms-excel',
- 'ppt' => 'application/powerpoint',
- 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
- 'wbxml' => 'application/wbxml',
- 'wmlc' => 'application/wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'gz' => 'application/x-gzip',
- 'gzip' => 'application/x-gzip',
- 'php' => 'application/x-httpd-php',
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => 'application/javascript',
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => 'application/x-tar',
- 'z' => 'application/x-compress',
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => 'application/x-zip',
- 'rar' => 'application/x-rar',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg',
- 'aif' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'aifc' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'rv' => 'video/vnd.rn-realvideo',
- 'wav' => 'audio/x-wav',
- 'jpg' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
- 'jpe' => 'image/jpeg',
- 'png' => 'image/png',
- 'gif' => 'image/gif',
- 'bmp' => 'image/bmp',
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'css' => 'text/css',
- 'html' => 'text/html',
- 'htm' => 'text/html',
- 'shtml' => 'text/html',
- 'txt' => 'text/plain',
- 'text' => 'text/plain',
- 'log' => 'text/plain',
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => 'application/xml',
- 'xsl' => 'application/xml',
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'avi' => 'video/x-msvideo',
- 'movie' => 'video/x-sgi-movie',
- 'doc' => 'application/msword',
- 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- 'dot' => 'application/msword',
- 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'word' => 'application/msword',
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822',
- 'json' => 'application/json',
- 'pem' => 'application/x-x509-user-cert',
- 'p10' => 'application/x-pkcs10',
- 'p12' => 'application/x-pkcs12',
- 'p7a' => 'application/x-pkcs7-signature',
- 'p7c' => 'application/pkcs7-mime',
- 'p7m' => 'application/pkcs7-mime',
- 'p7r' => 'application/x-pkcs7-certreqresp',
- 'p7s' => 'application/pkcs7-signature',
- 'crt' => 'application/x-x509-ca-cert',
- 'crl' => 'application/pkix-crl',
- 'der' => 'application/x-x509-ca-cert',
- 'kdb' => 'application/octet-stream',
- 'pgp' => 'application/pgp',
- 'gpg' => 'application/gpg-keys',
- 'sst' => 'application/octet-stream',
- 'csr' => 'application/octet-stream',
- 'rsa' => 'application/x-pkcs7',
- 'cer' => 'application/pkix-cert',
- '3g2' => 'video/3gpp2',
- '3gp' => 'video/3gp',
- 'mp4' => 'video/mp4',
- 'm4a' => 'audio/x-m4a',
- 'f4v' => 'video/mp4',
- 'webm' => 'video/webm',
- 'aac' => 'audio/x-acc',
- 'm4u' => 'application/vnd.mpegurl',
- 'm3u' => 'text/plain',
- 'xspf' => 'application/xspf+xml',
- 'vlc' => 'application/videolan',
- 'wmv' => 'video/x-ms-wmv',
- 'au' => 'audio/x-au',
- 'ac3' => 'audio/ac3',
- 'flac' => 'audio/x-flac',
- 'ogg' => 'audio/ogg',
- 'kmz' => 'application/vnd.google-earth.kmz',
- 'kml' => 'application/vnd.google-earth.kml+xml',
- 'ics' => 'text/calendar',
- 'zsh' => 'text/x-scriptzsh',
- '7zip' => 'application/x-7z-compressed',
- 'cdr' => 'application/cdr',
- 'wma' => 'audio/x-ms-wma',
- 'jar' => 'application/java-archive',
- ];
+ return static::$extensionToMimeTypeMap;
}
}
diff --git a/application/vendor/league/flysystem/src/Util/StreamHasher.php b/application/vendor/league/flysystem/src/Util/StreamHasher.php
new file mode 100644
index 0000000..938ec5d
--- /dev/null
+++ b/application/vendor/league/flysystem/src/Util/StreamHasher.php
@@ -0,0 +1,36 @@
+algo = $algo;
+ }
+
+ /**
+ * @param resource $resource
+ *
+ * @return string
+ */
+ public function hash($resource)
+ {
+ rewind($resource);
+ $context = hash_init($this->algo);
+ hash_update_stream($context, $resource);
+ fclose($resource);
+
+ return hash_final($context);
+ }
+}
diff --git a/application/vendor/monolog/monolog/.php_cs b/application/vendor/monolog/monolog/.php_cs
deleted file mode 100644
index 2511e98..0000000
--- a/application/vendor/monolog/monolog/.php_cs
+++ /dev/null
@@ -1,15 +0,0 @@
-files()
- ->name('*.php')
- ->in(__DIR__.'/src')
- ->in(__DIR__.'/tests')
-;
-
-return Symfony\CS\Config\Config::create()
- ->fixers(array(
- 'psr0', 'encoding', 'short_tag', 'braces', 'elseif', 'eof_ending', 'function_declaration', 'indentation', 'line_after_namespace', 'linefeed', 'lowercase_constants', 'lowercase_keywords', 'multiple_use', 'php_closing_tag', 'trailing_spaces', 'visibility', 'duplicate_semicolon', 'extra_empty_lines', 'include', 'namespace_no_leading_whitespace', 'object_operator', 'operators_spaces', 'phpdoc_params', 'return', 'single_array_no_trailing_comma', 'spaces_cast', 'standardize_not_equal', 'ternary_spaces', 'unused_use', 'whitespacy_lines',
- ))
- ->finder($finder)
-;
diff --git a/application/vendor/monolog/monolog/CHANGELOG.md b/application/vendor/monolog/monolog/CHANGELOG.md
new file mode 100644
index 0000000..9b0f528
--- /dev/null
+++ b/application/vendor/monolog/monolog/CHANGELOG.md
@@ -0,0 +1,388 @@
+### 1.25.1 (2019-09-06)
+
+ * Fixed forward-compatible interfaces to be compatible with Monolog 1.x too.
+
+### 1.25.0 (2019-09-06)
+
+ * Deprecated SlackbotHandler, use SlackWebhookHandler or SlackHandler instead
+ * Deprecated RavenHandler, use sentry/sentry 2.x and their Sentry\Monolog\Handler instead
+ * Deprecated HipChatHandler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead
+ * Added forward-compatible interfaces and traits FormattableHandlerInterface, FormattableHandlerTrait, ProcessableHandlerInterface, ProcessableHandlerTrait. If you use modern PHP and want to make code compatible with Monolog 1 and 2 this can help. You will have to require at least Monolog 1.25 though.
+ * Added support for RFC3164 (outdated BSD syslog protocol) to SyslogUdpHandler
+ * Fixed issue in GroupHandler and WhatFailureGroupHandler where setting multiple processors would duplicate records
+ * Fixed issue in SignalHandler restarting syscalls functionality
+ * Fixed normalizers handling of exception backtraces to avoid serializing arguments in some cases
+ * Fixed ZendMonitorHandler to work with the latest Zend Server versions
+ * Fixed ChromePHPHandler to avoid sending more data than latest Chrome versions allow in headers (4KB down from 256KB).
+
+### 1.24.0 (2018-11-05)
+
+ * BC Notice: If you are extending any of the Monolog's Formatters' `normalize` method, make sure you add the new `$depth = 0` argument to your function signature to avoid strict PHP warnings.
+ * Added a `ResettableInterface` in order to reset/reset/clear/flush handlers and processors
+ * Added a `ProcessorInterface` as an optional way to label a class as being a processor (mostly useful for autowiring dependency containers)
+ * Added a way to log signals being received using Monolog\SignalHandler
+ * Added ability to customize error handling at the Logger level using Logger::setExceptionHandler
+ * Added InsightOpsHandler to migrate users of the LogEntriesHandler
+ * Added protection to NormalizerHandler against circular and very deep structures, it now stops normalizing at a depth of 9
+ * Added capture of stack traces to ErrorHandler when logging PHP errors
+ * Added RavenHandler support for a `contexts` context or extra key to forward that to Sentry's contexts
+ * Added forwarding of context info to FluentdFormatter
+ * Added SocketHandler::setChunkSize to override the default chunk size in case you must send large log lines to rsyslog for example
+ * Added ability to extend/override BrowserConsoleHandler
+ * Added SlackWebhookHandler::getWebhookUrl and SlackHandler::getToken to enable class extensibility
+ * Added SwiftMailerHandler::getSubjectFormatter to enable class extensibility
+ * Dropped official support for HHVM in test builds
+ * Fixed normalization of exception traces when call_user_func is used to avoid serializing objects and the data they contain
+ * Fixed naming of fields in Slack handler, all field names are now capitalized in all cases
+ * Fixed HipChatHandler bug where slack dropped messages randomly
+ * Fixed normalization of objects in Slack handlers
+ * Fixed support for PHP7's Throwable in NewRelicHandler
+ * Fixed race bug when StreamHandler sometimes incorrectly reported it failed to create a directory
+ * Fixed table row styling issues in HtmlFormatter
+ * Fixed RavenHandler dropping the message when logging exception
+ * Fixed WhatFailureGroupHandler skipping processors when using handleBatch
+ and implement it where possible
+ * Fixed display of anonymous class names
+
+### 1.23.0 (2017-06-19)
+
+ * Improved SyslogUdpHandler's support for RFC5424 and added optional `$ident` argument
+ * Fixed GelfHandler truncation to be per field and not per message
+ * Fixed compatibility issue with PHP <5.3.6
+ * Fixed support for headless Chrome in ChromePHPHandler
+ * Fixed support for latest Aws SDK in DynamoDbHandler
+ * Fixed support for SwiftMailer 6.0+ in SwiftMailerHandler
+
+### 1.22.1 (2017-03-13)
+
+ * Fixed lots of minor issues in the new Slack integrations
+ * Fixed support for allowInlineLineBreaks in LineFormatter when formatting exception backtraces
+
+### 1.22.0 (2016-11-26)
+
+ * Added SlackbotHandler and SlackWebhookHandler to set up Slack integration more easily
+ * Added MercurialProcessor to add mercurial revision and branch names to log records
+ * Added support for AWS SDK v3 in DynamoDbHandler
+ * Fixed fatal errors occuring when normalizing generators that have been fully consumed
+ * Fixed RollbarHandler to include a level (rollbar level), monolog_level (original name), channel and datetime (unix)
+ * Fixed RollbarHandler not flushing records automatically, calling close() explicitly is not necessary anymore
+ * Fixed SyslogUdpHandler to avoid sending empty frames
+ * Fixed a few PHP 7.0 and 7.1 compatibility issues
+
+### 1.21.0 (2016-07-29)
+
+ * Break: Reverted the addition of $context when the ErrorHandler handles regular php errors from 1.20.0 as it was causing issues
+ * Added support for more formats in RotatingFileHandler::setFilenameFormat as long as they have Y, m and d in order
+ * Added ability to format the main line of text the SlackHandler sends by explictly setting a formatter on the handler
+ * Added information about SoapFault instances in NormalizerFormatter
+ * Added $handleOnlyReportedErrors option on ErrorHandler::registerErrorHandler (default true) to allow logging of all errors no matter the error_reporting level
+
+### 1.20.0 (2016-07-02)
+
+ * Added FingersCrossedHandler::activate() to manually trigger the handler regardless of the activation policy
+ * Added StreamHandler::getUrl to retrieve the stream's URL
+ * Added ability to override addRow/addTitle in HtmlFormatter
+ * Added the $context to context information when the ErrorHandler handles a regular php error
+ * Deprecated RotatingFileHandler::setFilenameFormat to only support 3 formats: Y, Y-m and Y-m-d
+ * Fixed WhatFailureGroupHandler to work with PHP7 throwables
+ * Fixed a few minor bugs
+
+### 1.19.0 (2016-04-12)
+
+ * Break: StreamHandler will not close streams automatically that it does not own. If you pass in a stream (not a path/url), then it will not close it for you. You can retrieve those using getStream() if needed
+ * Added DeduplicationHandler to remove duplicate records from notifications across multiple requests, useful for email or other notifications on errors
+ * Added ability to use `%message%` and other LineFormatter replacements in the subject line of emails sent with NativeMailHandler and SwiftMailerHandler
+ * Fixed HipChatHandler handling of long messages
+
+### 1.18.2 (2016-04-02)
+
+ * Fixed ElasticaFormatter to use more precise dates
+ * Fixed GelfMessageFormatter sending too long messages
+
+### 1.18.1 (2016-03-13)
+
+ * Fixed SlackHandler bug where slack dropped messages randomly
+ * Fixed RedisHandler issue when using with the PHPRedis extension
+ * Fixed AmqpHandler content-type being incorrectly set when using with the AMQP extension
+ * Fixed BrowserConsoleHandler regression
+
+### 1.18.0 (2016-03-01)
+
+ * Added optional reduction of timestamp precision via `Logger->useMicrosecondTimestamps(false)`, disabling it gets you a bit of performance boost but reduces the precision to the second instead of microsecond
+ * Added possibility to skip some extra stack frames in IntrospectionProcessor if you have some library wrapping Monolog that is always adding frames
+ * Added `Logger->withName` to clone a logger (keeping all handlers) with a new name
+ * Added FluentdFormatter for the Fluentd unix socket protocol
+ * Added HandlerWrapper base class to ease the creation of handler wrappers, just extend it and override as needed
+ * Added support for replacing context sub-keys using `%context.*%` in LineFormatter
+ * Added support for `payload` context value in RollbarHandler
+ * Added setRelease to RavenHandler to describe the application version, sent with every log
+ * Added support for `fingerprint` context value in RavenHandler
+ * Fixed JSON encoding errors that would gobble up the whole log record, we now handle those more gracefully by dropping chars as needed
+ * Fixed write timeouts in SocketHandler and derivatives, set to 10sec by default, lower it with `setWritingTimeout()`
+ * Fixed PHP7 compatibility with regard to Exception/Throwable handling in a few places
+
+### 1.17.2 (2015-10-14)
+
+ * Fixed ErrorHandler compatibility with non-Monolog PSR-3 loggers
+ * Fixed SlackHandler handling to use slack functionalities better
+ * Fixed SwiftMailerHandler bug when sending multiple emails they all had the same id
+ * Fixed 5.3 compatibility regression
+
+### 1.17.1 (2015-08-31)
+
+ * Fixed RollbarHandler triggering PHP notices
+
+### 1.17.0 (2015-08-30)
+
+ * Added support for `checksum` and `release` context/extra values in RavenHandler
+ * Added better support for exceptions in RollbarHandler
+ * Added UidProcessor::getUid
+ * Added support for showing the resource type in NormalizedFormatter
+ * Fixed IntrospectionProcessor triggering PHP notices
+
+### 1.16.0 (2015-08-09)
+
+ * Added IFTTTHandler to notify ifttt.com triggers
+ * Added Logger::setHandlers() to allow setting/replacing all handlers
+ * Added $capSize in RedisHandler to cap the log size
+ * Fixed StreamHandler creation of directory to only trigger when the first log write happens
+ * Fixed bug in the handling of curl failures
+ * Fixed duplicate logging of fatal errors when both error and fatal error handlers are registered in monolog's ErrorHandler
+ * Fixed missing fatal errors records with handlers that need to be closed to flush log records
+ * Fixed TagProcessor::addTags support for associative arrays
+
+### 1.15.0 (2015-07-12)
+
+ * Added addTags and setTags methods to change a TagProcessor
+ * Added automatic creation of directories if they are missing for a StreamHandler to open a log file
+ * Added retry functionality to Loggly, Cube and Mandrill handlers so they retry up to 5 times in case of network failure
+ * Fixed process exit code being incorrectly reset to 0 if ErrorHandler::registerExceptionHandler was used
+ * Fixed HTML/JS escaping in BrowserConsoleHandler
+ * Fixed JSON encoding errors being silently suppressed (PHP 5.5+ only)
+
+### 1.14.0 (2015-06-19)
+
+ * Added PHPConsoleHandler to send record to Chrome's PHP Console extension and library
+ * Added support for objects implementing __toString in the NormalizerFormatter
+ * Added support for HipChat's v2 API in HipChatHandler
+ * Added Logger::setTimezone() to initialize the timezone monolog should use in case date.timezone isn't correct for your app
+ * Added an option to send formatted message instead of the raw record on PushoverHandler via ->useFormattedMessage(true)
+ * Fixed curl errors being silently suppressed
+
+### 1.13.1 (2015-03-09)
+
+ * Fixed regression in HipChat requiring a new token to be created
+
+### 1.13.0 (2015-03-05)
+
+ * Added Registry::hasLogger to check for the presence of a logger instance
+ * Added context.user support to RavenHandler
+ * Added HipChat API v2 support in the HipChatHandler
+ * Added NativeMailerHandler::addParameter to pass params to the mail() process
+ * Added context data to SlackHandler when $includeContextAndExtra is true
+ * Added ability to customize the Swift_Message per-email in SwiftMailerHandler
+ * Fixed SwiftMailerHandler to lazily create message instances if a callback is provided
+ * Fixed serialization of INF and NaN values in Normalizer and LineFormatter
+
+### 1.12.0 (2014-12-29)
+
+ * Break: HandlerInterface::isHandling now receives a partial record containing only a level key. This was always the intent and does not break any Monolog handler but is strictly speaking a BC break and you should check if you relied on any other field in your own handlers.
+ * Added PsrHandler to forward records to another PSR-3 logger
+ * Added SamplingHandler to wrap around a handler and include only every Nth record
+ * Added MongoDBFormatter to support better storage with MongoDBHandler (it must be enabled manually for now)
+ * Added exception codes in the output of most formatters
+ * Added LineFormatter::includeStacktraces to enable exception stack traces in logs (uses more than one line)
+ * Added $useShortAttachment to SlackHandler to minify attachment size and $includeExtra to append extra data
+ * Added $host to HipChatHandler for users of private instances
+ * Added $transactionName to NewRelicHandler and support for a transaction_name context value
+ * Fixed MandrillHandler to avoid outputing API call responses
+ * Fixed some non-standard behaviors in SyslogUdpHandler
+
+### 1.11.0 (2014-09-30)
+
+ * Break: The NewRelicHandler extra and context data are now prefixed with extra_ and context_ to avoid clashes. Watch out if you have scripts reading those from the API and rely on names
+ * Added WhatFailureGroupHandler to suppress any exception coming from the wrapped handlers and avoid chain failures if a logging service fails
+ * Added MandrillHandler to send emails via the Mandrillapp.com API
+ * Added SlackHandler to log records to a Slack.com account
+ * Added FleepHookHandler to log records to a Fleep.io account
+ * Added LogglyHandler::addTag to allow adding tags to an existing handler
+ * Added $ignoreEmptyContextAndExtra to LineFormatter to avoid empty [] at the end
+ * Added $useLocking to StreamHandler and RotatingFileHandler to enable flock() while writing
+ * Added support for PhpAmqpLib in the AmqpHandler
+ * Added FingersCrossedHandler::clear and BufferHandler::clear to reset them between batches in long running jobs
+ * Added support for adding extra fields from $_SERVER in the WebProcessor
+ * Fixed support for non-string values in PrsLogMessageProcessor
+ * Fixed SwiftMailer messages being sent with the wrong date in long running scripts
+ * Fixed minor PHP 5.6 compatibility issues
+ * Fixed BufferHandler::close being called twice
+
+### 1.10.0 (2014-06-04)
+
+ * Added Logger::getHandlers() and Logger::getProcessors() methods
+ * Added $passthruLevel argument to FingersCrossedHandler to let it always pass some records through even if the trigger level is not reached
+ * Added support for extra data in NewRelicHandler
+ * Added $expandNewlines flag to the ErrorLogHandler to create multiple log entries when a message has multiple lines
+
+### 1.9.1 (2014-04-24)
+
+ * Fixed regression in RotatingFileHandler file permissions
+ * Fixed initialization of the BufferHandler to make sure it gets flushed after receiving records
+ * Fixed ChromePHPHandler and FirePHPHandler's activation strategies to be more conservative
+
+### 1.9.0 (2014-04-20)
+
+ * Added LogEntriesHandler to send logs to a LogEntries account
+ * Added $filePermissions to tweak file mode on StreamHandler and RotatingFileHandler
+ * Added $useFormatting flag to MemoryProcessor to make it send raw data in bytes
+ * Added support for table formatting in FirePHPHandler via the table context key
+ * Added a TagProcessor to add tags to records, and support for tags in RavenHandler
+ * Added $appendNewline flag to the JsonFormatter to enable using it when logging to files
+ * Added sound support to the PushoverHandler
+ * Fixed multi-threading support in StreamHandler
+ * Fixed empty headers issue when ChromePHPHandler received no records
+ * Fixed default format of the ErrorLogHandler
+
+### 1.8.0 (2014-03-23)
+
+ * Break: the LineFormatter now strips newlines by default because this was a bug, set $allowInlineLineBreaks to true if you need them
+ * Added BrowserConsoleHandler to send logs to any browser's console via console.log() injection in the output
+ * Added FilterHandler to filter records and only allow those of a given list of levels through to the wrapped handler
+ * Added FlowdockHandler to send logs to a Flowdock account
+ * Added RollbarHandler to send logs to a Rollbar account
+ * Added HtmlFormatter to send prettier log emails with colors for each log level
+ * Added GitProcessor to add the current branch/commit to extra record data
+ * Added a Monolog\Registry class to allow easier global access to pre-configured loggers
+ * Added support for the new official graylog2/gelf-php lib for GelfHandler, upgrade if you can by replacing the mlehner/gelf-php requirement
+ * Added support for HHVM
+ * Added support for Loggly batch uploads
+ * Added support for tweaking the content type and encoding in NativeMailerHandler
+ * Added $skipClassesPartials to tweak the ignored classes in the IntrospectionProcessor
+ * Fixed batch request support in GelfHandler
+
+### 1.7.0 (2013-11-14)
+
+ * Added ElasticSearchHandler to send logs to an Elastic Search server
+ * Added DynamoDbHandler and ScalarFormatter to send logs to Amazon's Dynamo DB
+ * Added SyslogUdpHandler to send logs to a remote syslogd server
+ * Added LogglyHandler to send logs to a Loggly account
+ * Added $level to IntrospectionProcessor so it only adds backtraces when needed
+ * Added $version to LogstashFormatter to allow using the new v1 Logstash format
+ * Added $appName to NewRelicHandler
+ * Added configuration of Pushover notification retries/expiry
+ * Added $maxColumnWidth to NativeMailerHandler to change the 70 chars default
+ * Added chainability to most setters for all handlers
+ * Fixed RavenHandler batch processing so it takes the message from the record with highest priority
+ * Fixed HipChatHandler batch processing so it sends all messages at once
+ * Fixed issues with eAccelerator
+ * Fixed and improved many small things
+
+### 1.6.0 (2013-07-29)
+
+ * Added HipChatHandler to send logs to a HipChat chat room
+ * Added ErrorLogHandler to send logs to PHP's error_log function
+ * Added NewRelicHandler to send logs to NewRelic's service
+ * Added Monolog\ErrorHandler helper class to register a Logger as exception/error/fatal handler
+ * Added ChannelLevelActivationStrategy for the FingersCrossedHandler to customize levels by channel
+ * Added stack traces output when normalizing exceptions (json output & co)
+ * Added Monolog\Logger::API constant (currently 1)
+ * Added support for ChromePHP's v4.0 extension
+ * Added support for message priorities in PushoverHandler, see $highPriorityLevel and $emergencyLevel
+ * Added support for sending messages to multiple users at once with the PushoverHandler
+ * Fixed RavenHandler's support for batch sending of messages (when behind a Buffer or FingersCrossedHandler)
+ * Fixed normalization of Traversables with very large data sets, only the first 1000 items are shown now
+ * Fixed issue in RotatingFileHandler when an open_basedir restriction is active
+ * Fixed minor issues in RavenHandler and bumped the API to Raven 0.5.0
+ * Fixed SyslogHandler issue when many were used concurrently with different facilities
+
+### 1.5.0 (2013-04-23)
+
+ * Added ProcessIdProcessor to inject the PID in log records
+ * Added UidProcessor to inject a unique identifier to all log records of one request/run
+ * Added support for previous exceptions in the LineFormatter exception serialization
+ * Added Monolog\Logger::getLevels() to get all available levels
+ * Fixed ChromePHPHandler so it avoids sending headers larger than Chrome can handle
+
+### 1.4.1 (2013-04-01)
+
+ * Fixed exception formatting in the LineFormatter to be more minimalistic
+ * Fixed RavenHandler's handling of context/extra data, requires Raven client >0.1.0
+ * Fixed log rotation in RotatingFileHandler to work with long running scripts spanning multiple days
+ * Fixed WebProcessor array access so it checks for data presence
+ * Fixed Buffer, Group and FingersCrossed handlers to make use of their processors
+
+### 1.4.0 (2013-02-13)
+
+ * Added RedisHandler to log to Redis via the Predis library or the phpredis extension
+ * Added ZendMonitorHandler to log to the Zend Server monitor
+ * Added the possibility to pass arrays of handlers and processors directly in the Logger constructor
+ * Added `$useSSL` option to the PushoverHandler which is enabled by default
+ * Fixed ChromePHPHandler and FirePHPHandler issue when multiple instances are used simultaneously
+ * Fixed header injection capability in the NativeMailHandler
+
+### 1.3.1 (2013-01-11)
+
+ * Fixed LogstashFormatter to be usable with stream handlers
+ * Fixed GelfMessageFormatter levels on Windows
+
+### 1.3.0 (2013-01-08)
+
+ * Added PSR-3 compliance, the `Monolog\Logger` class is now an instance of `Psr\Log\LoggerInterface`
+ * Added PsrLogMessageProcessor that you can selectively enable for full PSR-3 compliance
+ * Added LogstashFormatter (combine with SocketHandler or StreamHandler to send logs to Logstash)
+ * Added PushoverHandler to send mobile notifications
+ * Added CouchDBHandler and DoctrineCouchDBHandler
+ * Added RavenHandler to send data to Sentry servers
+ * Added support for the new MongoClient class in MongoDBHandler
+ * Added microsecond precision to log records' timestamps
+ * Added `$flushOnOverflow` param to BufferHandler to flush by batches instead of losing
+ the oldest entries
+ * Fixed normalization of objects with cyclic references
+
+### 1.2.1 (2012-08-29)
+
+ * Added new $logopts arg to SyslogHandler to provide custom openlog options
+ * Fixed fatal error in SyslogHandler
+
+### 1.2.0 (2012-08-18)
+
+ * Added AmqpHandler (for use with AMQP servers)
+ * Added CubeHandler
+ * Added NativeMailerHandler::addHeader() to send custom headers in mails
+ * Added the possibility to specify more than one recipient in NativeMailerHandler
+ * Added the possibility to specify float timeouts in SocketHandler
+ * Added NOTICE and EMERGENCY levels to conform with RFC 5424
+ * Fixed the log records to use the php default timezone instead of UTC
+ * Fixed BufferHandler not being flushed properly on PHP fatal errors
+ * Fixed normalization of exotic resource types
+ * Fixed the default format of the SyslogHandler to avoid duplicating datetimes in syslog
+
+### 1.1.0 (2012-04-23)
+
+ * Added Monolog\Logger::isHandling() to check if a handler will
+ handle the given log level
+ * Added ChromePHPHandler
+ * Added MongoDBHandler
+ * Added GelfHandler (for use with Graylog2 servers)
+ * Added SocketHandler (for use with syslog-ng for example)
+ * Added NormalizerFormatter
+ * Added the possibility to change the activation strategy of the FingersCrossedHandler
+ * Added possibility to show microseconds in logs
+ * Added `server` and `referer` to WebProcessor output
+
+### 1.0.2 (2011-10-24)
+
+ * Fixed bug in IE with large response headers and FirePHPHandler
+
+### 1.0.1 (2011-08-25)
+
+ * Added MemoryPeakUsageProcessor and MemoryUsageProcessor
+ * Added Monolog\Logger::getName() to get a logger's channel name
+
+### 1.0.0 (2011-07-06)
+
+ * Added IntrospectionProcessor to get info from where the logger was called
+ * Fixed WebProcessor in CLI
+
+### 1.0.0-RC1 (2011-07-01)
+
+ * Initial release
diff --git a/application/vendor/monolog/monolog/CHANGELOG.mdown b/application/vendor/monolog/monolog/CHANGELOG.mdown
deleted file mode 100644
index 2aaeec5..0000000
--- a/application/vendor/monolog/monolog/CHANGELOG.mdown
+++ /dev/null
@@ -1,265 +0,0 @@
-### 1.17.2 (2015-10-14)
-
- * Fixed ErrorHandler compatibility with non-Monolog PSR-3 loggers
- * Fixed SlackHandler handling to use slack functionalities better
- * Fixed SwiftMailerHandler bug when sending multiple emails they all had the same id
- * Fixed 5.3 compatibility regression
-
-### 1.17.1 (2015-08-31)
-
- * Fixed RollbarHandler triggering PHP notices
-
-### 1.17.0 (2015-08-30)
-
- * Added support for `checksum` and `release` context/extra values in RavenHandler
- * Added better support for exceptions in RollbarHandler
- * Added UidProcessor::getUid
- * Added support for showing the resource type in NormalizedFormatter
- * Fixed IntrospectionProcessor triggering PHP notices
-
-### 1.16.0 (2015-08-09)
-
- * Added IFTTTHandler to notify ifttt.com triggers
- * Added Logger::setHandlers() to allow setting/replacing all handlers
- * Added $capSize in RedisHandler to cap the log size
- * Fixed StreamHandler creation of directory to only trigger when the first log write happens
- * Fixed bug in the handling of curl failures
- * Fixed duplicate logging of fatal errors when both error and fatal error handlers are registered in monolog's ErrorHandler
- * Fixed missing fatal errors records with handlers that need to be closed to flush log records
- * Fixed TagProcessor::addTags support for associative arrays
-
-### 1.15.0 (2015-07-12)
-
- * Added addTags and setTags methods to change a TagProcessor
- * Added automatic creation of directories if they are missing for a StreamHandler to open a log file
- * Added retry functionality to Loggly, Cube and Mandrill handlers so they retry up to 5 times in case of network failure
- * Fixed process exit code being incorrectly reset to 0 if ErrorHandler::registerExceptionHandler was used
- * Fixed HTML/JS escaping in BrowserConsoleHandler
- * Fixed JSON encoding errors being silently suppressed (PHP 5.5+ only)
-
-### 1.14.0 (2015-06-19)
-
- * Added PHPConsoleHandler to send record to Chrome's PHP Console extension and library
- * Added support for objects implementing __toString in the NormalizerFormatter
- * Added support for HipChat's v2 API in HipChatHandler
- * Added Logger::setTimezone() to initialize the timezone monolog should use in case date.timezone isn't correct for your app
- * Added an option to send formatted message instead of the raw record on PushoverHandler via ->useFormattedMessage(true)
- * Fixed curl errors being silently suppressed
-
-### 1.13.1 (2015-03-09)
-
- * Fixed regression in HipChat requiring a new token to be created
-
-### 1.13.0 (2015-03-05)
-
- * Added Registry::hasLogger to check for the presence of a logger instance
- * Added context.user support to RavenHandler
- * Added HipChat API v2 support in the HipChatHandler
- * Added NativeMailerHandler::addParameter to pass params to the mail() process
- * Added context data to SlackHandler when $includeContextAndExtra is true
- * Added ability to customize the Swift_Message per-email in SwiftMailerHandler
- * Fixed SwiftMailerHandler to lazily create message instances if a callback is provided
- * Fixed serialization of INF and NaN values in Normalizer and LineFormatter
-
-### 1.12.0 (2014-12-29)
-
- * Break: HandlerInterface::isHandling now receives a partial record containing only a level key. This was always the intent and does not break any Monolog handler but is strictly speaking a BC break and you should check if you relied on any other field in your own handlers.
- * Added PsrHandler to forward records to another PSR-3 logger
- * Added SamplingHandler to wrap around a handler and include only every Nth record
- * Added MongoDBFormatter to support better storage with MongoDBHandler (it must be enabled manually for now)
- * Added exception codes in the output of most formatters
- * Added LineFormatter::includeStacktraces to enable exception stack traces in logs (uses more than one line)
- * Added $useShortAttachment to SlackHandler to minify attachment size and $includeExtra to append extra data
- * Added $host to HipChatHandler for users of private instances
- * Added $transactionName to NewRelicHandler and support for a transaction_name context value
- * Fixed MandrillHandler to avoid outputing API call responses
- * Fixed some non-standard behaviors in SyslogUdpHandler
-
-### 1.11.0 (2014-09-30)
-
- * Break: The NewRelicHandler extra and context data are now prefixed with extra_ and context_ to avoid clashes. Watch out if you have scripts reading those from the API and rely on names
- * Added WhatFailureGroupHandler to suppress any exception coming from the wrapped handlers and avoid chain failures if a logging service fails
- * Added MandrillHandler to send emails via the Mandrillapp.com API
- * Added SlackHandler to log records to a Slack.com account
- * Added FleepHookHandler to log records to a Fleep.io account
- * Added LogglyHandler::addTag to allow adding tags to an existing handler
- * Added $ignoreEmptyContextAndExtra to LineFormatter to avoid empty [] at the end
- * Added $useLocking to StreamHandler and RotatingFileHandler to enable flock() while writing
- * Added support for PhpAmqpLib in the AmqpHandler
- * Added FingersCrossedHandler::clear and BufferHandler::clear to reset them between batches in long running jobs
- * Added support for adding extra fields from $_SERVER in the WebProcessor
- * Fixed support for non-string values in PrsLogMessageProcessor
- * Fixed SwiftMailer messages being sent with the wrong date in long running scripts
- * Fixed minor PHP 5.6 compatibility issues
- * Fixed BufferHandler::close being called twice
-
-### 1.10.0 (2014-06-04)
-
- * Added Logger::getHandlers() and Logger::getProcessors() methods
- * Added $passthruLevel argument to FingersCrossedHandler to let it always pass some records through even if the trigger level is not reached
- * Added support for extra data in NewRelicHandler
- * Added $expandNewlines flag to the ErrorLogHandler to create multiple log entries when a message has multiple lines
-
-### 1.9.1 (2014-04-24)
-
- * Fixed regression in RotatingFileHandler file permissions
- * Fixed initialization of the BufferHandler to make sure it gets flushed after receiving records
- * Fixed ChromePHPHandler and FirePHPHandler's activation strategies to be more conservative
-
-### 1.9.0 (2014-04-20)
-
- * Added LogEntriesHandler to send logs to a LogEntries account
- * Added $filePermissions to tweak file mode on StreamHandler and RotatingFileHandler
- * Added $useFormatting flag to MemoryProcessor to make it send raw data in bytes
- * Added support for table formatting in FirePHPHandler via the table context key
- * Added a TagProcessor to add tags to records, and support for tags in RavenHandler
- * Added $appendNewline flag to the JsonFormatter to enable using it when logging to files
- * Added sound support to the PushoverHandler
- * Fixed multi-threading support in StreamHandler
- * Fixed empty headers issue when ChromePHPHandler received no records
- * Fixed default format of the ErrorLogHandler
-
-### 1.8.0 (2014-03-23)
-
- * Break: the LineFormatter now strips newlines by default because this was a bug, set $allowInlineLineBreaks to true if you need them
- * Added BrowserConsoleHandler to send logs to any browser's console via console.log() injection in the output
- * Added FilterHandler to filter records and only allow those of a given list of levels through to the wrapped handler
- * Added FlowdockHandler to send logs to a Flowdock account
- * Added RollbarHandler to send logs to a Rollbar account
- * Added HtmlFormatter to send prettier log emails with colors for each log level
- * Added GitProcessor to add the current branch/commit to extra record data
- * Added a Monolog\Registry class to allow easier global access to pre-configured loggers
- * Added support for the new official graylog2/gelf-php lib for GelfHandler, upgrade if you can by replacing the mlehner/gelf-php requirement
- * Added support for HHVM
- * Added support for Loggly batch uploads
- * Added support for tweaking the content type and encoding in NativeMailerHandler
- * Added $skipClassesPartials to tweak the ignored classes in the IntrospectionProcessor
- * Fixed batch request support in GelfHandler
-
-### 1.7.0 (2013-11-14)
-
- * Added ElasticSearchHandler to send logs to an Elastic Search server
- * Added DynamoDbHandler and ScalarFormatter to send logs to Amazon's Dynamo DB
- * Added SyslogUdpHandler to send logs to a remote syslogd server
- * Added LogglyHandler to send logs to a Loggly account
- * Added $level to IntrospectionProcessor so it only adds backtraces when needed
- * Added $version to LogstashFormatter to allow using the new v1 Logstash format
- * Added $appName to NewRelicHandler
- * Added configuration of Pushover notification retries/expiry
- * Added $maxColumnWidth to NativeMailerHandler to change the 70 chars default
- * Added chainability to most setters for all handlers
- * Fixed RavenHandler batch processing so it takes the message from the record with highest priority
- * Fixed HipChatHandler batch processing so it sends all messages at once
- * Fixed issues with eAccelerator
- * Fixed and improved many small things
-
-### 1.6.0 (2013-07-29)
-
- * Added HipChatHandler to send logs to a HipChat chat room
- * Added ErrorLogHandler to send logs to PHP's error_log function
- * Added NewRelicHandler to send logs to NewRelic's service
- * Added Monolog\ErrorHandler helper class to register a Logger as exception/error/fatal handler
- * Added ChannelLevelActivationStrategy for the FingersCrossedHandler to customize levels by channel
- * Added stack traces output when normalizing exceptions (json output & co)
- * Added Monolog\Logger::API constant (currently 1)
- * Added support for ChromePHP's v4.0 extension
- * Added support for message priorities in PushoverHandler, see $highPriorityLevel and $emergencyLevel
- * Added support for sending messages to multiple users at once with the PushoverHandler
- * Fixed RavenHandler's support for batch sending of messages (when behind a Buffer or FingersCrossedHandler)
- * Fixed normalization of Traversables with very large data sets, only the first 1000 items are shown now
- * Fixed issue in RotatingFileHandler when an open_basedir restriction is active
- * Fixed minor issues in RavenHandler and bumped the API to Raven 0.5.0
- * Fixed SyslogHandler issue when many were used concurrently with different facilities
-
-### 1.5.0 (2013-04-23)
-
- * Added ProcessIdProcessor to inject the PID in log records
- * Added UidProcessor to inject a unique identifier to all log records of one request/run
- * Added support for previous exceptions in the LineFormatter exception serialization
- * Added Monolog\Logger::getLevels() to get all available levels
- * Fixed ChromePHPHandler so it avoids sending headers larger than Chrome can handle
-
-### 1.4.1 (2013-04-01)
-
- * Fixed exception formatting in the LineFormatter to be more minimalistic
- * Fixed RavenHandler's handling of context/extra data, requires Raven client >0.1.0
- * Fixed log rotation in RotatingFileHandler to work with long running scripts spanning multiple days
- * Fixed WebProcessor array access so it checks for data presence
- * Fixed Buffer, Group and FingersCrossed handlers to make use of their processors
-
-### 1.4.0 (2013-02-13)
-
- * Added RedisHandler to log to Redis via the Predis library or the phpredis extension
- * Added ZendMonitorHandler to log to the Zend Server monitor
- * Added the possibility to pass arrays of handlers and processors directly in the Logger constructor
- * Added `$useSSL` option to the PushoverHandler which is enabled by default
- * Fixed ChromePHPHandler and FirePHPHandler issue when multiple instances are used simultaneously
- * Fixed header injection capability in the NativeMailHandler
-
-### 1.3.1 (2013-01-11)
-
- * Fixed LogstashFormatter to be usable with stream handlers
- * Fixed GelfMessageFormatter levels on Windows
-
-### 1.3.0 (2013-01-08)
-
- * Added PSR-3 compliance, the `Monolog\Logger` class is now an instance of `Psr\Log\LoggerInterface`
- * Added PsrLogMessageProcessor that you can selectively enable for full PSR-3 compliance
- * Added LogstashFormatter (combine with SocketHandler or StreamHandler to send logs to Logstash)
- * Added PushoverHandler to send mobile notifications
- * Added CouchDBHandler and DoctrineCouchDBHandler
- * Added RavenHandler to send data to Sentry servers
- * Added support for the new MongoClient class in MongoDBHandler
- * Added microsecond precision to log records' timestamps
- * Added `$flushOnOverflow` param to BufferHandler to flush by batches instead of losing
- the oldest entries
- * Fixed normalization of objects with cyclic references
-
-### 1.2.1 (2012-08-29)
-
- * Added new $logopts arg to SyslogHandler to provide custom openlog options
- * Fixed fatal error in SyslogHandler
-
-### 1.2.0 (2012-08-18)
-
- * Added AmqpHandler (for use with AMQP servers)
- * Added CubeHandler
- * Added NativeMailerHandler::addHeader() to send custom headers in mails
- * Added the possibility to specify more than one recipient in NativeMailerHandler
- * Added the possibility to specify float timeouts in SocketHandler
- * Added NOTICE and EMERGENCY levels to conform with RFC 5424
- * Fixed the log records to use the php default timezone instead of UTC
- * Fixed BufferHandler not being flushed properly on PHP fatal errors
- * Fixed normalization of exotic resource types
- * Fixed the default format of the SyslogHandler to avoid duplicating datetimes in syslog
-
-### 1.1.0 (2012-04-23)
-
- * Added Monolog\Logger::isHandling() to check if a handler will
- handle the given log level
- * Added ChromePHPHandler
- * Added MongoDBHandler
- * Added GelfHandler (for use with Graylog2 servers)
- * Added SocketHandler (for use with syslog-ng for example)
- * Added NormalizerFormatter
- * Added the possibility to change the activation strategy of the FingersCrossedHandler
- * Added possibility to show microseconds in logs
- * Added `server` and `referer` to WebProcessor output
-
-### 1.0.2 (2011-10-24)
-
- * Fixed bug in IE with large response headers and FirePHPHandler
-
-### 1.0.1 (2011-08-25)
-
- * Added MemoryPeakUsageProcessor and MemoryUsageProcessor
- * Added Monolog\Logger::getName() to get a logger's channel name
-
-### 1.0.0 (2011-07-06)
-
- * Added IntrospectionProcessor to get info from where the logger was called
- * Fixed WebProcessor in CLI
-
-### 1.0.0-RC1 (2011-07-01)
-
- * Initial release
diff --git a/application/vendor/monolog/monolog/LICENSE b/application/vendor/monolog/monolog/LICENSE
index 56e08d5..1647321 100644
--- a/application/vendor/monolog/monolog/LICENSE
+++ b/application/vendor/monolog/monolog/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2015 Jordi Boggiano
+Copyright (c) 2011-2016 Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/application/vendor/monolog/monolog/README.md b/application/vendor/monolog/monolog/README.md
new file mode 100644
index 0000000..a578eb2
--- /dev/null
+++ b/application/vendor/monolog/monolog/README.md
@@ -0,0 +1,94 @@
+# Monolog - Logging for PHP [![Build Status](https://img.shields.io/travis/Seldaek/monolog.svg)](https://travis-ci.org/Seldaek/monolog)
+
+[![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
+[![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
+
+
+Monolog sends your logs to files, sockets, inboxes, databases and various
+web services. See the complete list of handlers below. Special handlers
+allow you to build advanced logging strategies.
+
+This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
+interface that you can type-hint against in your own libraries to keep
+a maximum of interoperability. You can also use it in your applications to
+make sure you can always use another compatible logger at a later time.
+As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels.
+Internally Monolog still uses its own level scheme since it predates PSR-3.
+
+## Installation
+
+Install the latest version with
+
+```bash
+$ composer require monolog/monolog
+```
+
+## Basic Usage
+
+```php
+pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
+
+// add records to the log
+$log->addWarning('Foo');
+$log->addError('Bar');
+```
+
+## Documentation
+
+- [Usage Instructions](doc/01-usage.md)
+- [Handlers, Formatters and Processors](doc/02-handlers-formatters-processors.md)
+- [Utility classes](doc/03-utilities.md)
+- [Extending Monolog](doc/04-extending.md)
+
+## Third Party Packages
+
+Third party handlers, formatters and processors are
+[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
+can also add your own there if you publish one.
+
+## About
+
+### Requirements
+
+- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM.
+
+### Submitting bugs and feature requests
+
+Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues)
+
+### Framework Integrations
+
+- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
+ can be used very easily with Monolog since it implements the interface.
+- [Symfony2](http://symfony.com) comes out of the box with Monolog.
+- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog.
+- [Laravel 4 & 5](http://laravel.com/) come out of the box with Monolog.
+- [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog.
+- [PPI](http://www.ppi.io/) comes out of the box with Monolog.
+- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin.
+- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer.
+- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog.
+- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog.
+- [Nette Framework](http://nette.org/en/) can be used with Monolog via [Kdyby/Monolog](https://github.com/Kdyby/Monolog) extension.
+- [Proton Micro Framework](https://github.com/alexbilbie/Proton) comes out of the box with Monolog.
+
+### Author
+
+Jordi Boggiano - -
+See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project.
+
+### License
+
+Monolog is licensed under the MIT License - see the `LICENSE` file for details
+
+### Acknowledgements
+
+This library is heavily inspired by Python's [Logbook](https://logbook.readthedocs.io/en/stable/)
+library, although most concepts have been adjusted to fit to the PHP world.
diff --git a/application/vendor/monolog/monolog/README.mdown b/application/vendor/monolog/monolog/README.mdown
deleted file mode 100644
index 7d8ade5..0000000
--- a/application/vendor/monolog/monolog/README.mdown
+++ /dev/null
@@ -1,95 +0,0 @@
-# Monolog - Logging for PHP [![Build Status](https://img.shields.io/travis/Seldaek/monolog.svg)](https://travis-ci.org/Seldaek/monolog)
-
-[![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
-[![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog)
-[![Reference Status](https://www.versioneye.com/php/monolog:monolog/reference_badge.svg)](https://www.versioneye.com/php/monolog:monolog/references)
-
-
-Monolog sends your logs to files, sockets, inboxes, databases and various
-web services. See the complete list of handlers below. Special handlers
-allow you to build advanced logging strategies.
-
-This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
-interface that you can type-hint against in your own libraries to keep
-a maximum of interoperability. You can also use it in your applications to
-make sure you can always use another compatible logger at a later time.
-As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels.
-Internally Monolog still uses its own level scheme since it predates PSR-3.
-
-## Installation
-
-Install the latest version with
-
-```bash
-$ composer require monolog/monolog
-```
-
-## Basic Usage
-
-```php
-pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
-
-// add records to the log
-$log->addWarning('Foo');
-$log->addError('Bar');
-```
-
-## Documentation
-
-- [Usage Instructions](doc/01-usage.md)
-- [Handlers, Formatters and Processors](doc/02-handlers-formatters-processors.md)
-- [Utility classes](doc/03-utilities.md)
-- [Extending Monolog](doc/04-extending.md)
-
-## Third Party Packages
-
-Third party handlers, formatters and processors are
-[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
-can also add your own there if you publish one.
-
-## About
-
-### Requirements
-
-- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM.
-
-### Submitting bugs and feature requests
-
-Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues)
-
-### Framework Integrations
-
-- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
- can be used very easily with Monolog since it implements the interface.
-- [Symfony2](http://symfony.com) comes out of the box with Monolog.
-- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog.
-- [Laravel 4 & 5](http://laravel.com/) come out of the box with Monolog.
-- [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog.
-- [PPI](http://www.ppi.io/) comes out of the box with Monolog.
-- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin.
-- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer.
-- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog.
-- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog.
-- [Nette Framework](http://nette.org/en/) can be used with Monolog via [Kdyby/Monolog](https://github.com/Kdyby/Monolog) extension.
-- [Proton Micro Framework](https://github.com/alexbilbie/Proton) comes out of the box with Monolog.
-
-### Author
-
-Jordi Boggiano - -
-See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project.
-
-### License
-
-Monolog is licensed under the MIT License - see the `LICENSE` file for details
-
-### Acknowledgements
-
-This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/)
-library, although most concepts have been adjusted to fit to the PHP world.
diff --git a/application/vendor/monolog/monolog/composer.json b/application/vendor/monolog/monolog/composer.json
index 2bb9053..097df87 100644
--- a/application/vendor/monolog/monolog/composer.json
+++ b/application/vendor/monolog/monolog/composer.json
@@ -19,12 +19,12 @@
"require-dev": {
"phpunit/phpunit": "~4.5",
"graylog2/gelf-php": "~1.0",
- "raven/raven": "^0.13",
+ "sentry/sentry": "^0.13",
"ruflin/elastica": ">=0.90 <3.0",
"doctrine/couchdb": "~1.0@dev",
- "aws/aws-sdk-php": "^2.4.9",
- "videlalvaro/php-amqplib": "~2.4",
- "swiftmailer/swiftmailer": "~5.3",
+ "aws/aws-sdk-php": "^2.4.9 || ^3.0",
+ "php-amqplib/php-amqplib": "~2.4",
+ "swiftmailer/swiftmailer": "^5.3|^6.0",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit-mock-objects": "2.3.0",
"jakub-onderka/php-parallel-lint": "0.9"
@@ -32,12 +32,13 @@
"_": "phpunit/phpunit-mock-objects required in 2.3.0 due to https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223 - needs hhvm 3.8+ on travis",
"suggest": {
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
- "raven/raven": "Allow sending log messages to a Sentry server",
+ "sentry/sentry": "Allow sending log messages to a Sentry server",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
- "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
+ "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
+ "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"php-console/php-console": "Allow sending log messages to Google Chrome"
@@ -53,12 +54,12 @@
},
"extra": {
"branch-alias": {
- "dev-master": "1.16.x-dev"
+ "dev-master": "2.0.x-dev"
}
},
"scripts": {
"test": [
- "parallel-lint . --exclude vendor",
+ "parallel-lint . --exclude vendor --exclude src/Monolog/Handler/FormattableHandlerInterface.php --exclude src/Monolog/Handler/FormattableHandlerTrait.php --exclude src/Monolog/Handler/ProcessableHandlerInterface.php --exclude src/Monolog/Handler/ProcessableHandlerTrait.php",
"phpunit"
]
}
diff --git a/application/vendor/monolog/monolog/doc/01-usage.md b/application/vendor/monolog/monolog/doc/01-usage.md
deleted file mode 100644
index 75bc402..0000000
--- a/application/vendor/monolog/monolog/doc/01-usage.md
+++ /dev/null
@@ -1,228 +0,0 @@
-# Using Monolog
-
-- [Installation](#installation)
-- [Core Concepts](#core-concepts)
-- [Log Levels](#log-levels)
-- [Configuring a logger](#configuring-a-logger)
-- [Adding extra data in the records](#adding-extra-data-in-the-records)
-- [Leveraging channels](#leveraging-channels)
-- [Customizing the log format](#customizing-the-log-format)
-
-## Installation
-
-Monolog is available on Packagist ([monolog/monolog](http://packagist.org/packages/monolog/monolog))
-and as such installable via [Composer](http://getcomposer.org/).
-
-```bash
-composer require monolog/monolog
-```
-
-If you do not use Composer, you can grab the code from GitHub, and use any
-PSR-0 compatible autoloader (e.g. the [Symfony2 ClassLoader component](https://github.com/symfony/ClassLoader))
-to load Monolog classes.
-
-## Core Concepts
-
-Every `Logger` instance has a channel (name) and a stack of handlers. Whenever
-you add a record to the logger, it traverses the handler stack. Each handler
-decides whether it fully handled the record, and if so, the propagation of the
-record ends there.
-
-This allows for flexible logging setups, for example having a `StreamHandler` at
-the bottom of the stack that will log anything to disk, and on top of that add
-a `MailHandler` that will send emails only when an error message is logged.
-Handlers also have a `$bubble` property which defines whether they block the
-record or not if they handled it. In this example, setting the `MailHandler`'s
-`$bubble` argument to false means that records handled by the `MailHandler` will
-not propagate to the `StreamHandler` anymore.
-
-You can create many `Logger`s, each defining a channel (e.g.: db, request,
-router, ..) and each of them combining various handlers, which can be shared
-or not. The channel is reflected in the logs and allows you to easily see or
-filter records.
-
-Each Handler also has a Formatter, a default one with settings that make sense
-will be created if you don't set one. The formatters normalize and format
-incoming records so that they can be used by the handlers to output useful
-information.
-
-Custom severity levels are not available. Only the eight
-[RFC 5424](http://tools.ietf.org/html/rfc5424) levels (debug, info, notice,
-warning, error, critical, alert, emergency) are present for basic filtering
-purposes, but for sorting and other use cases that would require
-flexibility, you should add Processors to the Logger that can add extra
-information (tags, user ip, ..) to the records before they are handled.
-
-## Log Levels
-
-Monolog supports the logging levels described by [RFC 5424](http://tools.ietf.org/html/rfc5424).
-
-- **DEBUG** (100): Detailed debug information.
-
-- **INFO** (200): Interesting events. Examples: User logs in, SQL logs.
-
-- **NOTICE** (250): Normal but significant events.
-
-- **WARNING** (300): Exceptional occurrences that are not errors. Examples:
- Use of deprecated APIs, poor use of an API, undesirable things that are not
- necessarily wrong.
-
-- **ERROR** (400): Runtime errors that do not require immediate action but
- should typically be logged and monitored.
-
-- **CRITICAL** (500): Critical conditions. Example: Application component
- unavailable, unexpected exception.
-
-- **ALERT** (550): Action must be taken immediately. Example: Entire website
- down, database unavailable, etc. This should trigger the SMS alerts and wake
- you up.
-
-- **EMERGENCY** (600): Emergency: system is unusable.
-
-## Configuring a logger
-
-Here is a basic setup to log to a file and to firephp on the DEBUG level:
-
-```php
-pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG));
-$logger->pushHandler(new FirePHPHandler());
-
-// You can now use your logger
-$logger->addInfo('My logger is now ready');
-```
-
-Let's explain it. The first step is to create the logger instance which will
-be used in your code. The argument is a channel name, which is useful when
-you use several loggers (see below for more details about it).
-
-The logger itself does not know how to handle a record. It delegates it to
-some handlers. The code above registers two handlers in the stack to allow
-handling records in two different ways.
-
-Note that the FirePHPHandler is called first as it is added on top of the
-stack. This allows you to temporarily add a logger with bubbling disabled if
-you want to override other configured loggers.
-
-> If you use Monolog standalone and are looking for an easy way to
-> configure many handlers, the [theorchard/monolog-cascade](https://github.com/theorchard/monolog-cascade)
-> can help you build complex logging configs via PHP arrays, yaml or json configs.
-
-## Adding extra data in the records
-
-Monolog provides two different ways to add extra informations along the simple
-textual message.
-
-### Using the logging context
-
-The first way is the context, allowing to pass an array of data along the
-record:
-
-```php
-addInfo('Adding a new user', array('username' => 'Seldaek'));
-```
-
-Simple handlers (like the StreamHandler for instance) will simply format
-the array to a string but richer handlers can take advantage of the context
-(FirePHP is able to display arrays in pretty way for instance).
-
-### Using processors
-
-The second way is to add extra data for all records by using a processor.
-Processors can be any callable. They will get the record as parameter and
-must return it after having eventually changed the `extra` part of it. Let's
-write a processor adding some dummy data in the record:
-
-```php
-pushProcessor(function ($record) {
- $record['extra']['dummy'] = 'Hello world!';
-
- return $record;
-});
-```
-
-Monolog provides some built-in processors that can be used in your project.
-Look at the [dedicated chapter](https://github.com/Seldaek/monolog/blob/master/doc/02-handlers-formatters-processors.md#processors) for the list.
-
-> Tip: processors can also be registered on a specific handler instead of
- the logger to apply only for this handler.
-
-## Leveraging channels
-
-Channels are a great way to identify to which part of the application a record
-is related. This is useful in big applications (and is leveraged by
-MonologBundle in Symfony2).
-
-Picture two loggers sharing a handler that writes to a single log file.
-Channels would allow you to identify the logger that issued every record.
-You can easily grep through the log files filtering this or that channel.
-
-```php
-pushHandler($stream);
-$logger->pushHandler($firephp);
-
-// Create a logger for the security-related stuff with a different channel
-$securityLogger = new Logger('security');
-$securityLogger->pushHandler($stream);
-$securityLogger->pushHandler($firephp);
-```
-
-## Customizing the log format
-
-In Monolog it's easy to customize the format of the logs written into files,
-sockets, mails, databases and other handlers. Most of the handlers use the
-
-```php
-$record['formatted']
-```
-
-value to be automatically put into the log device. This value depends on the
-formatter settings. You can choose between predefined formatter classes or
-write your own (e.g. a multiline text file for human-readable output).
-
-To configure a predefined formatter class, just set it as the handler's field:
-
-```php
-// the default date format is "Y-m-d H:i:s"
-$dateFormat = "Y n j, g:i a";
-// the default output format is "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
-$output = "%datetime% > %level_name% > %message% %context% %extra%\n";
-// finally, create a formatter
-$formatter = new LineFormatter($output, $dateFormat);
-
-// Create a handler
-$stream = new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG);
-$stream->setFormatter($formatter);
-// bind it to a logger object
-$securityLogger = new Logger('security');
-$securityLogger->pushHandler($stream);
-```
-
-You may also reuse the same formatter between multiple handlers and share those
-handlers between multiple loggers.
-
-[Handlers, Formatters and Processors](02-handlers-formatters-processors.md) →
diff --git a/application/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md b/application/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md
deleted file mode 100644
index 90f8fce..0000000
--- a/application/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md
+++ /dev/null
@@ -1,142 +0,0 @@
-# Handlers, Formatters and Processors
-
-- [Handlers](#handlers)
- - [Log to files and syslog](#log-to-files-and-syslog)
- - [Send alerts and emails](#send-alerts-and-emails)
- - [Log specific servers and networked logging](#log-specific-servers-and-networked-logging)
- - [Logging in development](#logging-in-development)
- - [Log to databases](#log-to-databases)
- - [Wrappers / Special Handlers](#wrappers--special-handlers)
-- [Formatters](#formatters)
-- [Processors](#processors)
-- [Third Party Packages](#third-party-packages)
-
-## Handlers
-
-### Log to files and syslog
-
-- _StreamHandler_: Logs records into any PHP stream, use this for log files.
-- _RotatingFileHandler_: Logs records to a file and creates one logfile per day.
- It will also delete files older than `$maxFiles`. You should use
- [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) for high profile
- setups though, this is just meant as a quick and dirty solution.
-- _SyslogHandler_: Logs records to the syslog.
-- _ErrorLogHandler_: Logs records to PHP's
- [`error_log()`](http://docs.php.net/manual/en/function.error-log.php) function.
-
-### Send alerts and emails
-
-- _NativeMailerHandler_: Sends emails using PHP's
- [`mail()`](http://php.net/manual/en/function.mail.php) function.
-- _SwiftMailerHandler_: Sends emails using a [`Swift_Mailer`](http://swiftmailer.org/) instance.
-- _PushoverHandler_: Sends mobile notifications via the [Pushover](https://www.pushover.net/) API.
-- _HipChatHandler_: Logs records to a [HipChat](http://hipchat.com) chat room using its API.
-- _FlowdockHandler_: Logs records to a [Flowdock](https://www.flowdock.com/) account.
-- _SlackHandler_: Logs records to a [Slack](https://www.slack.com/) account.
-- _MandrillHandler_: Sends emails via the Mandrill API using a [`Swift_Message`](http://swiftmailer.org/) instance.
-- _FleepHookHandler_: Logs records to a [Fleep](https://fleep.io/) conversation using Webhooks.
-- _IFTTTHandler_: Notifies an [IFTTT](https://ifttt.com/maker) trigger with the log channel, level name and message.
-
-### Log specific servers and networked logging
-
-- _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this
- for UNIX and TCP sockets. See an [example](sockets.md).
-- _AmqpHandler_: Logs records to an [amqp](http://www.amqp.org/) compatible
- server. Requires the [php-amqp](http://pecl.php.net/package/amqp) extension (1.0+).
-- _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server.
-- _CubeHandler_: Logs records to a [Cube](http://square.github.com/cube/) server.
-- _RavenHandler_: Logs records to a [Sentry](http://getsentry.com/) server using
- [raven](https://packagist.org/packages/raven/raven).
-- _ZendMonitorHandler_: Logs records to the Zend Monitor present in Zend Server.
-- _NewRelicHandler_: Logs records to a [NewRelic](http://newrelic.com/) application.
-- _LogglyHandler_: Logs records to a [Loggly](http://www.loggly.com/) account.
-- _RollbarHandler_: Logs records to a [Rollbar](https://rollbar.com/) account.
-- _SyslogUdpHandler_: Logs records to a remote [Syslogd](http://www.rsyslog.com/) server.
-- _LogEntriesHandler_: Logs records to a [LogEntries](http://logentries.com/) account.
-
-### Logging in development
-
-- _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing
- inline `console` messages within [FireBug](http://getfirebug.com/).
-- _ChromePHPHandler_: Handler for [ChromePHP](http://www.chromephp.com/), providing
- inline `console` messages within Chrome.
-- _BrowserConsoleHandler_: Handler to send logs to browser's Javascript `console` with
- no browser extension required. Most browsers supporting `console` API are supported.
-- _PHPConsoleHandler_: Handler for [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef), providing
- inline `console` and notification popup messages within Chrome.
-
-### Log to databases
-
-- _RedisHandler_: Logs records to a [redis](http://redis.io) server.
-- _MongoDBHandler_: Handler to write records in MongoDB via a
- [Mongo](http://pecl.php.net/package/mongo) extension connection.
-- _CouchDBHandler_: Logs records to a CouchDB server.
-- _DoctrineCouchDBHandler_: Logs records to a CouchDB server via the Doctrine CouchDB ODM.
-- _ElasticSearchHandler_: Logs records to an Elastic Search server.
-- _DynamoDbHandler_: Logs records to a DynamoDB table with the [AWS SDK](https://github.com/aws/aws-sdk-php).
-
-### Wrappers / Special Handlers
-
-- _FingersCrossedHandler_: A very interesting wrapper. It takes a logger as
- parameter and will accumulate log records of all levels until a record
- exceeds the defined severity level. At which point it delivers all records,
- including those of lower severity, to the handler it wraps. This means that
- until an error actually happens you will not see anything in your logs, but
- when it happens you will have the full information, including debug and info
- records. This provides you with all the information you need, but only when
- you need it.
-- _WhatFailureGroupHandler_: This handler extends the _GroupHandler_ ignoring
- exceptions raised by each child handler. This allows you to ignore issues
- where a remote tcp connection may have died but you do not want your entire
- application to crash and may wish to continue to log to other handlers.
-- _BufferHandler_: This handler will buffer all the log records it receives
- until `close()` is called at which point it will call `handleBatch()` on the
- handler it wraps with all the log messages at once. This is very useful to
- send an email with all records at once for example instead of having one mail
- for every log record.
-- _GroupHandler_: This handler groups other handlers. Every record received is
- sent to all the handlers it is configured with.
-- _FilterHandler_: This handler only lets records of the given levels through
- to the wrapped handler.
-- _SamplingHandler_: Wraps around another handler and lets you sample records
- if you only want to store some of them.
-- _NullHandler_: Any record it can handle will be thrown away. This can be used
- to put on top of an existing handler stack to disable it temporarily.
-- _PsrHandler_: Can be used to forward log records to an existing PSR-3 logger
-- _TestHandler_: Used for testing, it records everything that is sent to it and
- has accessors to read out the information.
-
-## Formatters
-
-- _LineFormatter_: Formats a log record into a one-line string.
-- _HtmlFormatter_: Used to format log records into a human readable html table, mainly suitable for emails.
-- _NormalizerFormatter_: Normalizes objects/resources down to strings so a record can easily be serialized/encoded.
-- _ScalarFormatter_: Used to format log records into an associative array of scalar values.
-- _JsonFormatter_: Encodes a log record into json.
-- _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler.
-- _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler.
-- _GelfMessageFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler.
-- _LogstashFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/latest).
-- _ElasticaFormatter_: Used to format log records into an Elastica\Document object, only useful for the ElasticSearchHandler.
-- _LogglyFormatter_: Used to format log records into Loggly messages, only useful for the LogglyHandler.
-- _FlowdockFormatter_: Used to format log records into Flowdock messages, only useful for the FlowdockHandler.
-- _MongoDBFormatter_: Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler.
-
-## Processors
-
-- _IntrospectionProcessor_: Adds the line/file/class/method from which the log call originated.
-- _WebProcessor_: Adds the current request URI, request method and client IP to a log record.
-- _MemoryUsageProcessor_: Adds the current memory usage to a log record.
-- _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record.
-- _ProcessIdProcessor_: Adds the process id to a log record.
-- _UidProcessor_: Adds a unique identifier to a log record.
-- _GitProcessor_: Adds the current git branch and commit to a log record.
-- _TagProcessor_: Adds an array of predefined tags to a log record.
-
-## Third Party Packages
-
-Third party handlers, formatters and processors are
-[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You
-can also add your own there if you publish one.
-
-← [Usage](01-usage.md) | [Utility classes](03-utilities.md) →
diff --git a/application/vendor/monolog/monolog/doc/03-utilities.md b/application/vendor/monolog/monolog/doc/03-utilities.md
deleted file mode 100644
index c62aa41..0000000
--- a/application/vendor/monolog/monolog/doc/03-utilities.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Utilities
-
-- _Registry_: The `Monolog\Registry` class lets you configure global loggers that you
- can then statically access from anywhere. It is not really a best practice but can
- help in some older codebases or for ease of use.
-- _ErrorHandler_: The `Monolog\ErrorHandler` class allows you to easily register
- a Logger instance as an exception handler, error handler or fatal error handler.
-- _ErrorLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain log
- level is reached.
-- _ChannelLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain
- log level is reached, depending on which channel received the log record.
-
-← [Handlers, Formatters and Processors](02-handlers-formatters-processors.md) | [Extending Monolog](04-extending.md) →
diff --git a/application/vendor/monolog/monolog/doc/04-extending.md b/application/vendor/monolog/monolog/doc/04-extending.md
deleted file mode 100644
index ebd9104..0000000
--- a/application/vendor/monolog/monolog/doc/04-extending.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# Extending Monolog
-
-Monolog is fully extensible, allowing you to adapt your logger to your needs.
-
-## Writing your own handler
-
-Monolog provides many built-in handlers. But if the one you need does not
-exist, you can write it and use it in your logger. The only requirement is
-to implement `Monolog\Handler\HandlerInterface`.
-
-Let's write a PDOHandler to log records to a database. We will extend the
-abstract class provided by Monolog to keep things DRY.
-
-```php
-pdo = $pdo;
- parent::__construct($level, $bubble);
- }
-
- protected function write(array $record)
- {
- if (!$this->initialized) {
- $this->initialize();
- }
-
- $this->statement->execute(array(
- 'channel' => $record['channel'],
- 'level' => $record['level'],
- 'message' => $record['formatted'],
- 'time' => $record['datetime']->format('U'),
- ));
- }
-
- private function initialize()
- {
- $this->pdo->exec(
- 'CREATE TABLE IF NOT EXISTS monolog '
- .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)'
- );
- $this->statement = $this->pdo->prepare(
- 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)'
- );
-
- $this->initialized = true;
- }
-}
-```
-
-You can now use this handler in your logger:
-
-```php
-pushHandler(new PDOHandler(new PDO('sqlite:logs.sqlite')));
-
-// You can now use your logger
-$logger->addInfo('My logger is now ready');
-```
-
-The `Monolog\Handler\AbstractProcessingHandler` class provides most of the
-logic needed for the handler, including the use of processors and the formatting
-of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``).
-
-← [Utility classes](03-utilities.md)
diff --git a/application/vendor/monolog/monolog/doc/sockets.md b/application/vendor/monolog/monolog/doc/sockets.md
deleted file mode 100644
index ea9cf0e..0000000
--- a/application/vendor/monolog/monolog/doc/sockets.md
+++ /dev/null
@@ -1,39 +0,0 @@
-Sockets Handler
-===============
-
-This handler allows you to write your logs to sockets using [fsockopen](http://php.net/fsockopen)
-or [pfsockopen](http://php.net/pfsockopen).
-
-Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening
-the connections between requests.
-
-You can use a `unix://` prefix to access unix sockets and `udp://` to open UDP sockets instead of the default TCP.
-
-Basic Example
--------------
-
-```php
-setPersistent(true);
-
-// Now add the handler
-$logger->pushHandler($handler, Logger::DEBUG);
-
-// You can now use your logger
-$logger->addInfo('My logger is now ready');
-
-```
-
-In this example, using syslog-ng, you should see the log on the log server:
-
- cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] []
-
diff --git a/application/vendor/monolog/monolog/phpunit.xml.dist b/application/vendor/monolog/monolog/phpunit.xml.dist
deleted file mode 100644
index 20d82b6..0000000
--- a/application/vendor/monolog/monolog/phpunit.xml.dist
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- tests/Monolog/
-
-
-
-
-
- src/Monolog/
-
-
-
-
-
-
-
diff --git a/application/vendor/monolog/monolog/src/Monolog/ErrorHandler.php b/application/vendor/monolog/monolog/src/Monolog/ErrorHandler.php
index f21eb28..adc55bd 100644
--- a/application/vendor/monolog/monolog/src/Monolog/ErrorHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/ErrorHandler.php
@@ -14,6 +14,7 @@
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Monolog\Handler\AbstractHandler;
+use Monolog\Registry;
/**
* Monolog error handler
@@ -33,10 +34,12 @@ class ErrorHandler
private $previousErrorHandler;
private $errorLevelMap;
+ private $handleOnlyReportedErrors;
private $hasFatalErrorHandler;
private $fatalLevel;
private $reservedMemory;
+ private $lastFatalTrace;
private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR);
public function __construct(LoggerInterface $logger)
@@ -57,6 +60,9 @@ public function __construct(LoggerInterface $logger)
*/
public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null)
{
+ //Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
+ class_exists('\\Psr\\Log\\LogLevel', true);
+
$handler = new static($logger);
if ($errorLevelMap !== false) {
$handler->registerErrorHandler($errorLevelMap);
@@ -80,13 +86,15 @@ public function registerExceptionHandler($level = null, $callPrevious = true)
}
}
- public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1)
+ public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1, $handleOnlyReportedErrors = true)
{
$prev = set_error_handler(array($this, 'handleError'), $errorTypes);
$this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
if ($callPrevious) {
$this->previousErrorHandler = $prev ?: true;
}
+
+ $this->handleOnlyReportedErrors = $handleOnlyReportedErrors;
}
public function registerFatalHandler($level = null, $reservedMemorySize = 20)
@@ -126,7 +134,7 @@ public function handleException($e)
{
$this->logger->log(
$this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel,
- sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
+ sprintf('Uncaught Exception %s: "%s" at %s line %s', Utils::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine()),
array('exception' => $e)
);
@@ -142,7 +150,7 @@ public function handleException($e)
*/
public function handleError($code, $message, $file = '', $line = 0, $context = array())
{
- if (!(error_reporting() & $code)) {
+ if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
return;
}
@@ -150,6 +158,13 @@ public function handleError($code, $message, $file = '', $line = 0, $context = a
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
$level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL;
$this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line));
+ } else {
+ // http://php.net/manual/en/function.debug-backtrace.php
+ // As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added.
+ // Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'.
+ $trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
+ array_shift($trace); // Exclude handleError from trace
+ $this->lastFatalTrace = $trace;
}
if ($this->previousErrorHandler === true) {
@@ -171,7 +186,7 @@ public function handleFatalError()
$this->logger->log(
$this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel,
'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'],
- array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'])
+ array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'], 'trace' => $this->lastFatalTrace)
);
if ($this->logger instanceof Logger) {
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php
index 56d3e27..9beda1e 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php
@@ -41,10 +41,9 @@ public function format(array $record)
{
// Retrieve the line and file if set and remove them from the formatted extra
$backtrace = 'unknown';
- if (isset($record['extra']['file']) && isset($record['extra']['line'])) {
+ if (isset($record['extra']['file'], $record['extra']['line'])) {
$backtrace = $record['extra']['file'].' : '.$record['extra']['line'];
- unset($record['extra']['file']);
- unset($record['extra']['line']);
+ unset($record['extra']['file'], $record['extra']['line']);
}
$message = array('message' => $record['message']);
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php
index b0b0cf0..4c556cf 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php
@@ -36,7 +36,9 @@ class ElasticaFormatter extends NormalizerFormatter
*/
public function __construct($index, $type)
{
- parent::__construct(\DateTime::ISO8601);
+ // elasticsearch requires a ISO 8601 format date with optional millisecond precision.
+ parent::__construct('Y-m-d\TH:i:s.uP');
+
$this->index = $index;
$this->type = $type;
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php
new file mode 100644
index 0000000..46a91ff
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php
@@ -0,0 +1,86 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * Class FluentdFormatter
+ *
+ * Serializes a log message to Fluentd unix socket protocol
+ *
+ * Fluentd config:
+ *
+ *
+ *
+ * Monolog setup:
+ *
+ * $logger = new Monolog\Logger('fluent.tag');
+ * $fluentHandler = new Monolog\Handler\SocketHandler('unix:///var/run/td-agent/td-agent.sock');
+ * $fluentHandler->setFormatter(new Monolog\Formatter\FluentdFormatter());
+ * $logger->pushHandler($fluentHandler);
+ *
+ * @author Andrius Putna
+ */
+class FluentdFormatter implements FormatterInterface
+{
+ /**
+ * @var bool $levelTag should message level be a part of the fluentd tag
+ */
+ protected $levelTag = false;
+
+ public function __construct($levelTag = false)
+ {
+ if (!function_exists('json_encode')) {
+ throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
+ }
+
+ $this->levelTag = (bool) $levelTag;
+ }
+
+ public function isUsingLevelsInTag()
+ {
+ return $this->levelTag;
+ }
+
+ public function format(array $record)
+ {
+ $tag = $record['channel'];
+ if ($this->levelTag) {
+ $tag .= '.' . strtolower($record['level_name']);
+ }
+
+ $message = array(
+ 'message' => $record['message'],
+ 'context' => $record['context'],
+ 'extra' => $record['extra'],
+ );
+
+ if (!$this->levelTag) {
+ $message['level'] = $record['level'];
+ $message['level_name'] = $record['level_name'];
+ }
+
+ return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
+ }
+
+ public function formatBatch(array $records)
+ {
+ $message = '';
+ foreach ($records as $record) {
+ $message .= $this->format($record);
+ }
+
+ return $message;
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php
index 1e43175..2c1b0e8 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php
@@ -22,6 +22,8 @@
*/
class GelfMessageFormatter extends NormalizerFormatter
{
+ const DEFAULT_MAX_LENGTH = 32766;
+
/**
* @var string the name of the system for the Gelf log message
*/
@@ -37,6 +39,11 @@ class GelfMessageFormatter extends NormalizerFormatter
*/
protected $contextPrefix;
+ /**
+ * @var int max length per field
+ */
+ protected $maxLength;
+
/**
* Translates Monolog log levels to Graylog2 log priorities.
*/
@@ -51,7 +58,7 @@ class GelfMessageFormatter extends NormalizerFormatter
Logger::EMERGENCY => 0,
);
- public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_')
+ public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $maxLength = null)
{
parent::__construct('U.u');
@@ -59,6 +66,7 @@ public function __construct($systemName = null, $extraPrefix = null, $contextPre
$this->extraPrefix = $extraPrefix;
$this->contextPrefix = $contextPrefix;
+ $this->maxLength = is_null($maxLength) ? self::DEFAULT_MAX_LENGTH : $maxLength;
}
/**
@@ -79,6 +87,13 @@ public function format(array $record)
->setHost($this->systemName)
->setLevel($this->logLevels[$record['level']]);
+ // message length + system name length + 200 for padding / metadata
+ $len = 200 + strlen((string) $record['message']) + strlen($this->systemName);
+
+ if ($len > $this->maxLength) {
+ $message->setShortMessage(substr($record['message'], 0, $this->maxLength));
+ }
+
if (isset($record['channel'])) {
$message->setFacility($record['channel']);
}
@@ -92,11 +107,23 @@ public function format(array $record)
}
foreach ($record['extra'] as $key => $val) {
- $message->setAdditional($this->extraPrefix . $key, is_scalar($val) ? $val : $this->toJson($val));
+ $val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
+ $len = strlen($this->extraPrefix . $key . $val);
+ if ($len > $this->maxLength) {
+ $message->setAdditional($this->extraPrefix . $key, substr($val, 0, $this->maxLength));
+ break;
+ }
+ $message->setAdditional($this->extraPrefix . $key, $val);
}
foreach ($record['context'] as $key => $val) {
- $message->setAdditional($this->contextPrefix . $key, is_scalar($val) ? $val : $this->toJson($val));
+ $val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
+ $len = strlen($this->contextPrefix . $key . $val);
+ if ($len > $this->maxLength) {
+ $message->setAdditional($this->contextPrefix . $key, substr($val, 0, $this->maxLength));
+ break;
+ }
+ $message->setAdditional($this->contextPrefix . $key, $val);
}
if (null === $message->getFile() && isset($record['context']['exception']['file'])) {
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php
index 255d288..dfc0b4a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php
@@ -24,7 +24,7 @@ class HtmlFormatter extends NormalizerFormatter
/**
* Translates Monolog log levels to html color priorities.
*/
- private $logLevels = array(
+ protected $logLevels = array(
Logger::DEBUG => '#cccccc',
Logger::INFO => '#468847',
Logger::NOTICE => '#3a87ad',
@@ -51,29 +51,30 @@ public function __construct($dateFormat = null)
* @param bool $escapeTd false if td content must not be html escaped
* @return string
*/
- private function addRow($th, $td = ' ', $escapeTd = true)
+ protected function addRow($th, $td = ' ', $escapeTd = true)
{
$th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8');
if ($escapeTd) {
$td = '
'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
';
}
- return "
\n
$th:
\n
".$td."
\n
";
+ return "
\n
$th:
\n
".$td."
\n
";
}
/**
* Create a HTML h1 tag
*
- * @param string $title Text to be in the h1
- * @param integer $level Error level
+ * @param string $title Text to be in the h1
+ * @param int $level Error level
* @return string
*/
- private function addTitle($title, $level)
+ protected function addTitle($title, $level)
{
$title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8');
return '
'.$title.'
';
}
+
/**
* Formats a log record.
*
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
index e5a1d2c..2ff119e 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
@@ -11,6 +11,10 @@
namespace Monolog\Formatter;
+use Exception;
+use Monolog\Utils;
+use Throwable;
+
/**
* Encodes whatever record data is passed to it as json
*
@@ -18,7 +22,7 @@
*
* @author Jordi Boggiano
*/
-class JsonFormatter implements FormatterInterface
+class JsonFormatter extends NormalizerFormatter
{
const BATCH_MODE_JSON = 1;
const BATCH_MODE_NEWLINES = 2;
@@ -26,8 +30,14 @@ class JsonFormatter implements FormatterInterface
protected $batchMode;
protected $appendNewline;
+ /**
+ * @var bool
+ */
+ protected $includeStacktraces = false;
+
/**
* @param int $batchMode
+ * @param bool $appendNewline
*/
public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true)
{
@@ -64,7 +74,7 @@ public function isAppendingNewlines()
*/
public function format(array $record)
{
- return json_encode($record) . ($this->appendNewline ? "\n" : '');
+ return $this->toJson($this->normalize($record), true) . ($this->appendNewline ? "\n" : '');
}
/**
@@ -82,6 +92,14 @@ public function formatBatch(array $records)
}
}
+ /**
+ * @param bool $include
+ */
+ public function includeStacktraces($include = true)
+ {
+ $this->includeStacktraces = $include;
+ }
+
/**
* Return a JSON-encoded array of records.
*
@@ -90,7 +108,7 @@ public function formatBatch(array $records)
*/
protected function formatBatchJson(array $records)
{
- return json_encode($records);
+ return $this->toJson($this->normalize($records), true);
}
/**
@@ -113,4 +131,78 @@ protected function formatBatchNewlines(array $records)
return implode("\n", $records);
}
+
+ /**
+ * Normalizes given $data.
+ *
+ * @param mixed $data
+ *
+ * @return mixed
+ */
+ protected function normalize($data, $depth = 0)
+ {
+ if ($depth > 9) {
+ return 'Over 9 levels deep, aborting normalization';
+ }
+
+ if (is_array($data) || $data instanceof \Traversable) {
+ $normalized = array();
+
+ $count = 1;
+ foreach ($data as $key => $value) {
+ if ($count++ > 1000) {
+ $normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization';
+ break;
+ }
+
+ $normalized[$key] = $this->normalize($value, $depth+1);
+ }
+
+ return $normalized;
+ }
+
+ if ($data instanceof Exception || $data instanceof Throwable) {
+ return $this->normalizeException($data);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Normalizes given exception with or without its own stack trace based on
+ * `includeStacktraces` property.
+ *
+ * @param Exception|Throwable $e
+ *
+ * @return array
+ */
+ protected function normalizeException($e)
+ {
+ // TODO 2.0 only check for Throwable
+ if (!$e instanceof Exception && !$e instanceof Throwable) {
+ throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
+ }
+
+ $data = array(
+ 'class' => Utils::getClass($e),
+ 'message' => $e->getMessage(),
+ 'code' => $e->getCode(),
+ 'file' => $e->getFile().':'.$e->getLine(),
+ );
+
+ if ($this->includeStacktraces) {
+ $trace = $e->getTrace();
+ foreach ($trace as $frame) {
+ if (isset($frame['file'])) {
+ $data['trace'][] = $frame['file'].':'.$frame['line'];
+ }
+ }
+ }
+
+ if ($previous = $e->getPrevious()) {
+ $data['previous'] = $this->normalizeException($previous);
+ }
+
+ return $data;
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
index 388e226..f98e1a6 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
@@ -11,7 +11,7 @@
namespace Monolog\Formatter;
-use Exception;
+use Monolog\Utils;
/**
* Formats incoming records into a one-line string
@@ -78,6 +78,14 @@ public function format(array $record)
}
}
+
+ foreach ($vars['context'] as $var => $val) {
+ if (false !== strpos($output, '%context.'.$var.'%')) {
+ $output = str_replace('%context.'.$var.'%', $this->stringify($val), $output);
+ unset($vars['context'][$var]);
+ }
+ }
+
if ($this->ignoreEmptyContextAndExtra) {
if (empty($vars['context'])) {
unset($vars['context']);
@@ -96,6 +104,11 @@ public function format(array $record)
}
}
+ // remove leftover %extra.xxx% and %context.xxx% if any
+ if (false !== strpos($output, '%')) {
+ $output = preg_replace('/%(?:extra|context)\..+?%/', '', $output);
+ }
+
return $output;
}
@@ -114,18 +127,23 @@ public function stringify($value)
return $this->replaceNewlines($this->convertToString($value));
}
- protected function normalizeException(Exception $e)
+ protected function normalizeException($e)
{
+ // TODO 2.0 only check for Throwable
+ if (!$e instanceof \Exception && !$e instanceof \Throwable) {
+ throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
+ }
+
$previousText = '';
if ($previous = $e->getPrevious()) {
do {
- $previousText .= ', '.get_class($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
+ $previousText .= ', '.Utils::getClass($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
} while ($previous = $previous->getPrevious());
}
- $str = '[object] ('.get_class($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
+ $str = '[object] ('.Utils::getClass($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
if ($this->includeStacktraces) {
- $str .= "\n[stacktrace]\n".$e->getTraceAsString();
+ $str .= "\n[stacktrace]\n".$e->getTraceAsString()."\n";
}
return $str;
@@ -151,6 +169,10 @@ protected function convertToString($data)
protected function replaceNewlines($str)
{
if ($this->allowInlineLineBreaks) {
+ if (0 === strpos($str, '{')) {
+ return str_replace(array('\r', '\n'), array("\r", "\n"), $str);
+ }
+
return $str;
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
index f02bceb..401859b 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
@@ -22,7 +22,7 @@ class LogglyFormatter extends JsonFormatter
* Overrides the default batch mode to new lines for compatibility with the
* Loggly bulk API.
*
- * @param integer $batchMode
+ * @param int $batchMode
*/
public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
index be21b2c..8f83bec 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
@@ -45,16 +45,16 @@ class LogstashFormatter extends NormalizerFormatter
protected $contextPrefix;
/**
- * @var integer logstash format version to use
+ * @var int logstash format version to use
*/
protected $version;
/**
- * @param string $applicationName the application that sends the data, used as the "type" field of logstash
- * @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
- * @param string $extraPrefix prefix for extra keys inside logstash "fields"
- * @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
- * @param integer $version the logstash format version to use, defaults to 0
+ * @param string $applicationName the application that sends the data, used as the "type" field of logstash
+ * @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
+ * @param string $extraPrefix prefix for extra keys inside logstash "fields"
+ * @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
+ * @param int $version the logstash format version to use, defaults to 0
*/
public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
{
@@ -92,7 +92,7 @@ protected function formatV0(array $record)
$message = array(
'@timestamp' => $record['datetime'],
'@source' => $this->systemName,
- '@fields' => array()
+ '@fields' => array(),
);
if (isset($record['message'])) {
$message['@message'] = $record['message'];
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php
index eb067bb..eb7be84 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php
@@ -11,6 +11,8 @@
namespace Monolog\Formatter;
+use Monolog\Utils;
+
/**
* Formats a record for use with the MongoDBHandler.
*
@@ -75,7 +77,7 @@ protected function formatArray(array $record, $nestingLevel = 0)
protected function formatObject($value, $nestingLevel)
{
$objectVars = get_object_vars($value);
- $objectVars['class'] = get_class($value);
+ $objectVars['class'] = Utils::getClass($value);
return $this->formatArray($objectVars, $nestingLevel);
}
@@ -83,7 +85,7 @@ protected function formatObject($value, $nestingLevel)
protected function formatException(\Exception $exception, $nestingLevel)
{
$formattedException = array(
- 'class' => get_class($exception),
+ 'class' => Utils::getClass($exception),
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'file' => $exception->getFile() . ':' . $exception->getLine(),
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
index 0361935..9865394 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
@@ -12,6 +12,7 @@
namespace Monolog\Formatter;
use Exception;
+use Monolog\Utils;
/**
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
@@ -55,8 +56,12 @@ public function formatBatch(array $records)
return $records;
}
- protected function normalize($data)
+ protected function normalize($data, $depth = 0)
{
+ if ($depth > 9) {
+ return 'Over 9 levels deep, aborting normalization';
+ }
+
if (null === $data || is_scalar($data)) {
if (is_float($data)) {
if (is_infinite($data)) {
@@ -70,16 +75,17 @@ protected function normalize($data)
return $data;
}
- if (is_array($data) || $data instanceof \Traversable) {
+ if (is_array($data)) {
$normalized = array();
$count = 1;
foreach ($data as $key => $value) {
- if ($count++ >= 1000) {
- $normalized['...'] = 'Over 1000 items, aborting normalization';
+ if ($count++ > 1000) {
+ $normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization';
break;
}
- $normalized[$key] = $this->normalize($value);
+
+ $normalized[$key] = $this->normalize($value, $depth+1);
}
return $normalized;
@@ -90,19 +96,20 @@ protected function normalize($data)
}
if (is_object($data)) {
- if ($data instanceof Exception) {
+ // TODO 2.0 only check for Throwable
+ if ($data instanceof Exception || (PHP_VERSION_ID > 70000 && $data instanceof \Throwable)) {
return $this->normalizeException($data);
}
// non-serializable objects that implement __toString stringified
if (method_exists($data, '__toString') && !$data instanceof \JsonSerializable) {
- $value = (string) $data;
+ $value = $data->__toString();
} else {
// the rest is json-serialized in some way
$value = $this->toJson($data, true);
}
- return sprintf("[object] (%s: %s)", get_class($data), $value);
+ return sprintf("[object] (%s: %s)", Utils::getClass($data), $value);
}
if (is_resource($data)) {
@@ -112,22 +119,38 @@ protected function normalize($data)
return '[unknown('.gettype($data).')]';
}
- protected function normalizeException(Exception $e)
+ protected function normalizeException($e)
{
+ // TODO 2.0 only check for Throwable
+ if (!$e instanceof Exception && !$e instanceof \Throwable) {
+ throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
+ }
+
$data = array(
- 'class' => get_class($e),
+ 'class' => Utils::getClass($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $e->getFile().':'.$e->getLine(),
);
+ if ($e instanceof \SoapFault) {
+ if (isset($e->faultcode)) {
+ $data['faultcode'] = $e->faultcode;
+ }
+
+ if (isset($e->faultactor)) {
+ $data['faultactor'] = $e->faultactor;
+ }
+
+ if (isset($e->detail)) {
+ $data['detail'] = $e->detail;
+ }
+ }
+
$trace = $e->getTrace();
foreach ($trace as $frame) {
if (isset($frame['file'])) {
$data['trace'][] = $frame['file'].':'.$frame['line'];
- } else {
- // We should again normalize the frames, because it might contain invalid items
- $data['trace'][] = $this->toJson($this->normalize($frame), true);
}
}
@@ -138,23 +161,72 @@ protected function normalizeException(Exception $e)
return $data;
}
+ /**
+ * Return the JSON representation of a value
+ *
+ * @param mixed $data
+ * @param bool $ignoreErrors
+ * @throws \RuntimeException if encoding fails and errors are not ignored
+ * @return string
+ */
protected function toJson($data, $ignoreErrors = false)
{
// suppress json_encode errors since it's twitchy with some inputs
if ($ignoreErrors) {
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- return @json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
- }
+ return @$this->jsonEncode($data);
+ }
- return @json_encode($data);
+ $json = $this->jsonEncode($data);
+
+ if ($json === false) {
+ $json = $this->handleJsonError(json_last_error(), $data);
}
+ return $json;
+ }
+
+ /**
+ * @param mixed $data
+ * @return string JSON encoded data or null on failure
+ */
+ private function jsonEncode($data)
+ {
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ }
+
+ return json_encode($data);
+ }
+
+ /**
+ * Handle a json_encode failure.
+ *
+ * If the failure is due to invalid string encoding, try to clean the
+ * input and encode again. If the second encoding attempt fails, the
+ * inital error is not encoding related or the input can't be cleaned then
+ * raise a descriptive exception.
+ *
+ * @param int $code return code of json_last_error function
+ * @param mixed $data data that was meant to be encoded
+ * @throws \RuntimeException if failure can't be corrected
+ * @return string JSON encoded data after error correction
+ */
+ private function handleJsonError($code, $data)
+ {
+ if ($code !== JSON_ERROR_UTF8) {
+ $this->throwEncodeError($code, $data);
+ }
+
+ if (is_string($data)) {
+ $this->detectAndCleanUtf8($data);
+ } elseif (is_array($data)) {
+ array_walk_recursive($data, array($this, 'detectAndCleanUtf8'));
} else {
- $json = json_encode($data);
+ $this->throwEncodeError($code, $data);
}
+ $json = $this->jsonEncode($data);
+
if ($json === false) {
$this->throwEncodeError(json_last_error(), $data);
}
@@ -165,8 +237,8 @@ protected function toJson($data, $ignoreErrors = false)
/**
* Throws an exception according to a given code with a customized message
*
- * @param int $code return code of json_last_error function
- * @param mixed $data data that was meant to be encoded
+ * @param int $code return code of json_last_error function
+ * @param mixed $data data that was meant to be encoded
* @throws \RuntimeException
*/
private function throwEncodeError($code, $data)
@@ -190,4 +262,36 @@ private function throwEncodeError($code, $data)
throw new \RuntimeException('JSON encoding failed: '.$msg.'. Encoding: '.var_export($data, true));
}
+
+ /**
+ * Detect invalid UTF-8 string characters and convert to valid UTF-8.
+ *
+ * Valid UTF-8 input will be left unmodified, but strings containing
+ * invalid UTF-8 codepoints will be reencoded as UTF-8 with an assumed
+ * original encoding of ISO-8859-15. This conversion may result in
+ * incorrect output if the actual encoding was not ISO-8859-15, but it
+ * will be clean UTF-8 output and will not rely on expensive and fragile
+ * detection algorithms.
+ *
+ * Function converts the input in place in the passed variable so that it
+ * can be used as a callback for array_walk_recursive.
+ *
+ * @param mixed &$data Input to check and convert if needed
+ * @private
+ */
+ public function detectAndCleanUtf8(&$data)
+ {
+ if (is_string($data) && !preg_match('//u', $data)) {
+ $data = preg_replace_callback(
+ '/[\x80-\xFF]+/',
+ function ($m) { return utf8_encode($m[0]); },
+ $data
+ );
+ $data = str_replace(
+ array('¤', '¦', '¨', '´', '¸', '¼', '½', '¾'),
+ array('€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'),
+ $data
+ );
+ }
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/application/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
index 654710a..65dba99 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
@@ -102,12 +102,12 @@ public function formatBatch(array $records)
throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter');
}
- protected function normalize($data)
+ protected function normalize($data, $depth = 0)
{
if (is_object($data) && !$data instanceof \DateTime) {
return $data;
}
- return parent::normalize($data);
+ return parent::normalize($data, $depth);
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
index 69ede49..92b9d45 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
@@ -11,16 +11,17 @@
namespace Monolog\Handler;
-use Monolog\Logger;
use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LineFormatter;
+use Monolog\Logger;
+use Monolog\ResettableInterface;
/**
* Base Handler class providing the Handler structure
*
* @author Jordi Boggiano
*/
-abstract class AbstractHandler implements HandlerInterface
+abstract class AbstractHandler implements HandlerInterface, ResettableInterface
{
protected $level = Logger::DEBUG;
protected $bubble = true;
@@ -32,8 +33,8 @@ abstract class AbstractHandler implements HandlerInterface
protected $processors = array();
/**
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($level = Logger::DEBUG, $bubble = true)
{
@@ -118,7 +119,7 @@ public function getFormatter()
/**
* Sets minimum logging level at which this handler will be triggered.
*
- * @param integer $level
+ * @param int|string $level Level or level name
* @return self
*/
public function setLevel($level)
@@ -131,7 +132,7 @@ public function setLevel($level)
/**
* Gets minimum logging level at which this handler will be triggered.
*
- * @return integer
+ * @return int
*/
public function getLevel()
{
@@ -141,8 +142,8 @@ public function getLevel()
/**
* Sets the bubbling behavior.
*
- * @param Boolean $bubble true means that this handler allows bubbling.
- * false means that bubbling is not permitted.
+ * @param bool $bubble true means that this handler allows bubbling.
+ * false means that bubbling is not permitted.
* @return self
*/
public function setBubble($bubble)
@@ -155,8 +156,8 @@ public function setBubble($bubble)
/**
* Gets the bubbling behavior.
*
- * @return Boolean true means that this handler allows bubbling.
- * false means that bubbling is not permitted.
+ * @return bool true means that this handler allows bubbling.
+ * false means that bubbling is not permitted.
*/
public function getBubble()
{
@@ -169,6 +170,17 @@ public function __destruct()
$this->close();
} catch (\Exception $e) {
// do nothing
+ } catch (\Throwable $e) {
+ // do nothing
+ }
+ }
+
+ public function reset()
+ {
+ foreach ($this->processors as $processor) {
+ if ($processor instanceof ResettableInterface) {
+ $processor->reset();
+ }
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
index 6f18f72..e1e8953 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
@@ -11,6 +11,8 @@
namespace Monolog\Handler;
+use Monolog\ResettableInterface;
+
/**
* Base Handler class providing the Handler structure
*
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
index 3eb83bd..8c76aca 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
@@ -53,9 +53,9 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
);
/**
- * @param mixed $facility
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param mixed $facility
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
{
@@ -70,6 +70,15 @@ public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubbl
$this->facilities['local5'] = LOG_LOCAL5;
$this->facilities['local6'] = LOG_LOCAL6;
$this->facilities['local7'] = LOG_LOCAL7;
+ } else {
+ $this->facilities['local0'] = 128; // LOG_LOCAL0
+ $this->facilities['local1'] = 136; // LOG_LOCAL1
+ $this->facilities['local2'] = 144; // LOG_LOCAL2
+ $this->facilities['local3'] = 152; // LOG_LOCAL3
+ $this->facilities['local4'] = 160; // LOG_LOCAL4
+ $this->facilities['local5'] = 168; // LOG_LOCAL5
+ $this->facilities['local6'] = 176; // LOG_LOCAL6
+ $this->facilities['local7'] = 184; // LOG_LOCAL7
}
// convert textual description of facility to syslog constant
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
index a28ba02..e5a46bc 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
@@ -55,39 +55,89 @@ public function __construct($exchange, $exchangeName = 'log', $level = Logger::D
protected function write(array $record)
{
$data = $record["formatted"];
-
- $routingKey = sprintf(
- '%s.%s',
- // TODO 2.0 remove substr call
- substr($record['level_name'], 0, 4),
- $record['channel']
- );
+ $routingKey = $this->getRoutingKey($record);
if ($this->exchange instanceof AMQPExchange) {
$this->exchange->publish(
$data,
- strtolower($routingKey),
+ $routingKey,
0,
array(
'delivery_mode' => 2,
- 'Content-type' => 'application/json'
+ 'content_type' => 'application/json',
)
);
} else {
$this->exchange->basic_publish(
- new AMQPMessage(
- (string) $data,
- array(
- 'delivery_mode' => 2,
- 'content_type' => 'application/json'
- )
- ),
+ $this->createAmqpMessage($data),
$this->exchangeName,
- strtolower($routingKey)
+ $routingKey
);
}
}
+ /**
+ * {@inheritDoc}
+ */
+ public function handleBatch(array $records)
+ {
+ if ($this->exchange instanceof AMQPExchange) {
+ parent::handleBatch($records);
+
+ return;
+ }
+
+ foreach ($records as $record) {
+ if (!$this->isHandling($record)) {
+ continue;
+ }
+
+ $record = $this->processRecord($record);
+ $data = $this->getFormatter()->format($record);
+
+ $this->exchange->batch_basic_publish(
+ $this->createAmqpMessage($data),
+ $this->exchangeName,
+ $this->getRoutingKey($record)
+ );
+ }
+
+ $this->exchange->publish_batch();
+ }
+
+ /**
+ * Gets the routing key for the AMQP exchange
+ *
+ * @param array $record
+ * @return string
+ */
+ protected function getRoutingKey(array $record)
+ {
+ $routingKey = sprintf(
+ '%s.%s',
+ // TODO 2.0 remove substr call
+ substr($record['level_name'], 0, 4),
+ $record['channel']
+ );
+
+ return strtolower($routingKey);
+ }
+
+ /**
+ * @param string $data
+ * @return AMQPMessage
+ */
+ private function createAmqpMessage($data)
+ {
+ return new AMQPMessage(
+ (string) $data,
+ array(
+ 'delivery_mode' => 2,
+ 'content_type' => 'application/json',
+ )
+ );
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
index a409952..23cf23b 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
@@ -31,7 +31,6 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
* Example of formatted string:
*
* You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}
- *
*/
protected function getDefaultFormatter()
{
@@ -44,12 +43,12 @@ protected function getDefaultFormatter()
protected function write(array $record)
{
// Accumulate records
- self::$records[] = $record;
+ static::$records[] = $record;
// Register shutdown handler if not already done
- if (PHP_SAPI !== 'cli' && !self::$initialized) {
- self::$initialized = true;
- register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send'));
+ if (!static::$initialized) {
+ static::$initialized = true;
+ $this->registerShutdownFunction();
}
}
@@ -59,54 +58,103 @@ protected function write(array $record)
*/
public static function send()
{
- $htmlTags = true;
+ $format = static::getResponseFormat();
+ if ($format === 'unknown') {
+ return;
+ }
+
+ if (count(static::$records)) {
+ if ($format === 'html') {
+ static::writeOutput('');
+ } elseif ($format === 'js') {
+ static::writeOutput(static::generateScript());
+ }
+ static::resetStatic();
+ }
+ }
+
+ public function close()
+ {
+ self::resetStatic();
+ }
+
+ public function reset()
+ {
+ self::resetStatic();
+ }
+
+ /**
+ * Forget all logged records
+ */
+ public static function resetStatic()
+ {
+ static::$records = array();
+ }
+
+ /**
+ * Wrapper for register_shutdown_function to allow overriding
+ */
+ protected function registerShutdownFunction()
+ {
+ if (PHP_SAPI !== 'cli') {
+ register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send'));
+ }
+ }
+
+ /**
+ * Wrapper for echo to allow overriding
+ *
+ * @param string $str
+ */
+ protected static function writeOutput($str)
+ {
+ echo $str;
+ }
+
+ /**
+ * Checks the format of the response
+ *
+ * If Content-Type is set to application/javascript or text/javascript -> js
+ * If Content-Type is set to text/html, or is unset -> html
+ * If Content-Type is anything else -> unknown
+ *
+ * @return string One of 'js', 'html' or 'unknown'
+ */
+ protected static function getResponseFormat()
+ {
// Check content type
foreach (headers_list() as $header) {
if (stripos($header, 'content-type:') === 0) {
// This handler only works with HTML and javascript outputs
// text/javascript is obsolete in favour of application/javascript, but still used
if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
- $htmlTags = false;
- } elseif (stripos($header, 'text/html') === false) {
- return;
+ return 'js';
+ }
+ if (stripos($header, 'text/html') === false) {
+ return 'unknown';
}
break;
}
}
- if (count(self::$records)) {
- if ($htmlTags) {
- echo '';
- } else {
- echo self::generateScript();
- }
- self::reset();
- }
- }
-
- /**
- * Forget all logged records
- */
- public static function reset()
- {
- self::$records = array();
+ return 'html';
}
private static function generateScript()
{
$script = array();
- foreach (self::$records as $record) {
- $context = self::dump('Context', $record['context']);
- $extra = self::dump('Extra', $record['extra']);
+ foreach (static::$records as $record) {
+ $context = static::dump('Context', $record['context']);
+ $extra = static::dump('Extra', $record['extra']);
if (empty($context) && empty($extra)) {
- $script[] = self::call_array('log', self::handleStyles($record['formatted']));
+ $script[] = static::call_array('log', static::handleStyles($record['formatted']));
} else {
$script = array_merge($script,
- array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))),
+ array(static::call_array('groupCollapsed', static::handleStyles($record['formatted']))),
$context,
$extra,
- array(self::call('groupEnd'))
+ array(static::call('groupEnd'))
);
}
}
@@ -116,19 +164,19 @@ private static function generateScript()
private static function handleStyles($formatted)
{
- $args = array(self::quote('font-weight: normal'));
+ $args = array(static::quote('font-weight: normal'));
$format = '%c' . $formatted;
preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
foreach (array_reverse($matches) as $match) {
- $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0]));
+ $args[] = static::quote(static::handleCustomStyles($match[2][0], $match[1][0]));
$args[] = '"font-weight: normal"';
$pos = $match[0][1];
$format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0]));
}
- array_unshift($args, self::quote($format));
+ array_unshift($args, static::quote($format));
return $args;
}
@@ -160,13 +208,13 @@ private static function dump($title, array $dict)
if (empty($dict)) {
return $script;
}
- $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title));
+ $script[] = static::call('log', static::quote('%c%s'), static::quote('font-weight: bold'), static::quote($title));
foreach ($dict as $key => $value) {
$value = json_encode($value);
if (empty($value)) {
- $value = self::quote('');
+ $value = static::quote('');
}
- $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value);
+ $script[] = static::call('log', static::quote('%s: %o'), static::quote($key), $value);
}
return $script;
@@ -182,7 +230,7 @@ private static function call()
$args = func_get_args();
$method = array_shift($args);
- return self::call_array($method, $args);
+ return static::call_array($method, $args);
}
private static function call_array($method, array $args)
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
index 6d8136f..61d1b50 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Logger;
+use Monolog\ResettableInterface;
/**
* Buffers all records until closing the handler and then pass them as batch.
@@ -32,10 +33,10 @@ class BufferHandler extends AbstractHandler
/**
* @param HandlerInterface $handler Handler.
- * @param integer $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
+ * @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
*/
public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false)
{
@@ -114,4 +115,15 @@ public function clear()
$this->bufferSize = 0;
$this->buffer = array();
}
+
+ public function reset()
+ {
+ $this->flush();
+
+ parent::reset();
+
+ if ($this->handler instanceof ResettableInterface) {
+ $this->handler->reset();
+ }
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
index b3f2963..ac98d5d 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
@@ -17,6 +17,8 @@
/**
* Handler sending logs to the ChromePHP extension (http://www.chromephp.com/)
*
+ * This also works out of the box with Firefox 43+
+ *
* @author Christophe Coevoet
*/
class ChromePHPHandler extends AbstractProcessingHandler
@@ -31,14 +33,19 @@ class ChromePHPHandler extends AbstractProcessingHandler
*/
const HEADER_NAME = 'X-ChromeLogger-Data';
+ /**
+ * Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+)
+ */
+ const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}';
+
protected static $initialized = false;
/**
* Tracks whether we sent too much data
*
- * Chrome limits the headers to 256KB, so when we sent 240KB we stop sending
+ * Chrome limits the headers to 4KB, so when we sent 3KB we stop sending
*
- * @var Boolean
+ * @var bool
*/
protected static $overflowed = false;
@@ -51,8 +58,8 @@ class ChromePHPHandler extends AbstractProcessingHandler
protected static $sendHeaders = true;
/**
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($level = Logger::DEBUG, $bubble = true)
{
@@ -129,7 +136,7 @@ protected function send()
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
- if (strlen($data) > 240 * 1024) {
+ if (strlen($data) > 3 * 1024) {
self::$overflowed = true;
$record = array(
@@ -167,7 +174,7 @@ protected function sendHeader($header, $content)
/**
* Verifies if the headers are accepted by the current user agent
*
- * @return Boolean
+ * @return bool
*/
protected function headersAccepted()
{
@@ -175,7 +182,7 @@ protected function headersAccepted()
return false;
}
- return preg_match('{\bChrome/\d+[\.\d+]*\b}', $_SERVER['HTTP_USER_AGENT']);
+ return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']);
}
/**
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
index b3687c3..cc98697 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
@@ -54,7 +54,7 @@ protected function write(array $record)
'ignore_errors' => true,
'max_redirects' => 0,
'header' => 'Content-type: application/json',
- )
+ ),
));
if (false === @file_get_contents($url, null, $context)) {
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
index e7dd854..96b3ca0 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
@@ -21,37 +21,37 @@
*/
class CubeHandler extends AbstractProcessingHandler
{
- private $udpConnection = null;
- private $httpConnection = null;
- private $scheme = null;
- private $host = null;
- private $port = null;
+ private $udpConnection;
+ private $httpConnection;
+ private $scheme;
+ private $host;
+ private $port;
private $acceptedSchemes = array('http', 'udp');
/**
* Create a Cube handler
*
* @throws \UnexpectedValueException when given url is not a valid url.
- * A valid url must consists of three parts : protocol://host:port
- * Only valid protocol used by Cube are http and udp
+ * A valid url must consist of three parts : protocol://host:port
+ * Only valid protocols used by Cube are http and udp
*/
public function __construct($url, $level = Logger::DEBUG, $bubble = true)
{
- $urlInfos = parse_url($url);
+ $urlInfo = parse_url($url);
- if (!isset($urlInfos['scheme']) || !isset($urlInfos['host']) || !isset($urlInfos['port'])) {
+ if (!isset($urlInfo['scheme'], $urlInfo['host'], $urlInfo['port'])) {
throw new \UnexpectedValueException('URL "'.$url.'" is not valid');
}
- if (!in_array($urlInfos['scheme'], $this->acceptedSchemes)) {
+ if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) {
throw new \UnexpectedValueException(
- 'Invalid protocol (' . $urlInfos['scheme'] . ').'
+ 'Invalid protocol (' . $urlInfo['scheme'] . ').'
. ' Valid options are ' . implode(', ', $this->acceptedSchemes));
}
- $this->scheme = $urlInfos['scheme'];
- $this->host = $urlInfos['host'];
- $this->port = $urlInfos['port'];
+ $this->scheme = $urlInfo['scheme'];
+ $this->host = $urlInfo['host'];
+ $this->port = $urlInfo['port'];
parent::__construct($level, $bubble);
}
@@ -59,7 +59,8 @@ public function __construct($url, $level = Logger::DEBUG, $bubble = true)
/**
* Establish a connection to an UDP socket
*
- * @throws \LogicException when unable to connect to the socket
+ * @throws \LogicException when unable to connect to the socket
+ * @throws MissingExtensionException when there is no socket extension
*/
protected function connectUdp()
{
@@ -79,6 +80,7 @@ protected function connectUdp()
/**
* Establish a connection to a http server
+ * @throws \LogicException when no curl extension
*/
protected function connectHttp()
{
@@ -140,10 +142,10 @@ private function writeHttp($data)
curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen('['.$data.']'))
- );
+ 'Content-Type: application/json',
+ 'Content-Length: ' . strlen('['.$data.']'),
+ ));
- Curl\Util::execute($ch, 5, false);
+ Curl\Util::execute($this->httpConnection, 5, false);
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php b/application/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php
index adbe4f4..48d30b3 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php
@@ -26,7 +26,7 @@ class Util
/**
* Executes a CURL request with optional retries and exception on failure
*
- * @param resource $ch curl handler
+ * @param resource $ch curl handler
* @throws \RuntimeException
*/
public static function execute($ch, $retries = 5, $closeAfterDone = true)
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php
new file mode 100644
index 0000000..35b55cb
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php
@@ -0,0 +1,169 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Simple handler wrapper that deduplicates log records across multiple requests
+ *
+ * It also includes the BufferHandler functionality and will buffer
+ * all messages until the end of the request or flush() is called.
+ *
+ * This works by storing all log records' messages above $deduplicationLevel
+ * to the file specified by $deduplicationStore. When further logs come in at the end of the
+ * request (or when flush() is called), all those above $deduplicationLevel are checked
+ * against the existing stored logs. If they match and the timestamps in the stored log is
+ * not older than $time seconds, the new log record is discarded. If no log record is new, the
+ * whole data set is discarded.
+ *
+ * This is mainly useful in combination with Mail handlers or things like Slack or HipChat handlers
+ * that send messages to people, to avoid spamming with the same message over and over in case of
+ * a major component failure like a database server being down which makes all requests fail in the
+ * same way.
+ *
+ * @author Jordi Boggiano
+ */
+class DeduplicationHandler extends BufferHandler
+{
+ /**
+ * @var string
+ */
+ protected $deduplicationStore;
+
+ /**
+ * @var int
+ */
+ protected $deduplicationLevel;
+
+ /**
+ * @var int
+ */
+ protected $time;
+
+ /**
+ * @var bool
+ */
+ private $gc = false;
+
+ /**
+ * @param HandlerInterface $handler Handler.
+ * @param string $deduplicationStore The file/path where the deduplication log should be kept
+ * @param int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes
+ * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(HandlerInterface $handler, $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, $time = 60, $bubble = true)
+ {
+ parent::__construct($handler, 0, Logger::DEBUG, $bubble, false);
+
+ $this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore;
+ $this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel);
+ $this->time = $time;
+ }
+
+ public function flush()
+ {
+ if ($this->bufferSize === 0) {
+ return;
+ }
+
+ $passthru = null;
+
+ foreach ($this->buffer as $record) {
+ if ($record['level'] >= $this->deduplicationLevel) {
+
+ $passthru = $passthru || !$this->isDuplicate($record);
+ if ($passthru) {
+ $this->appendRecord($record);
+ }
+ }
+ }
+
+ // default of null is valid as well as if no record matches duplicationLevel we just pass through
+ if ($passthru === true || $passthru === null) {
+ $this->handler->handleBatch($this->buffer);
+ }
+
+ $this->clear();
+
+ if ($this->gc) {
+ $this->collectLogs();
+ }
+ }
+
+ private function isDuplicate(array $record)
+ {
+ if (!file_exists($this->deduplicationStore)) {
+ return false;
+ }
+
+ $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ if (!is_array($store)) {
+ return false;
+ }
+
+ $yesterday = time() - 86400;
+ $timestampValidity = $record['datetime']->getTimestamp() - $this->time;
+ $expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']);
+
+ for ($i = count($store) - 1; $i >= 0; $i--) {
+ list($timestamp, $level, $message) = explode(':', $store[$i], 3);
+
+ if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) {
+ return true;
+ }
+
+ if ($timestamp < $yesterday) {
+ $this->gc = true;
+ }
+ }
+
+ return false;
+ }
+
+ private function collectLogs()
+ {
+ if (!file_exists($this->deduplicationStore)) {
+ return false;
+ }
+
+ $handle = fopen($this->deduplicationStore, 'rw+');
+ flock($handle, LOCK_EX);
+ $validLogs = array();
+
+ $timestampValidity = time() - $this->time;
+
+ while (!feof($handle)) {
+ $log = fgets($handle);
+ if (substr($log, 0, 10) >= $timestampValidity) {
+ $validLogs[] = $log;
+ }
+ }
+
+ ftruncate($handle, 0);
+ rewind($handle);
+ foreach ($validLogs as $log) {
+ fwrite($handle, $log);
+ }
+
+ flock($handle, LOCK_UN);
+ fclose($handle);
+
+ $this->gc = false;
+ }
+
+ private function appendRecord(array $record)
+ {
+ file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND);
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
index e7f843c..237b71f 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
@@ -11,8 +11,9 @@
namespace Monolog\Handler;
-use Aws\Common\Aws;
+use Aws\Sdk;
use Aws\DynamoDb\DynamoDbClient;
+use Aws\DynamoDb\Marshaler;
use Monolog\Formatter\ScalarFormatter;
use Monolog\Logger;
@@ -36,16 +37,29 @@ class DynamoDbHandler extends AbstractProcessingHandler
*/
protected $table;
+ /**
+ * @var int
+ */
+ protected $version;
+
+ /**
+ * @var Marshaler
+ */
+ protected $marshaler;
+
/**
* @param DynamoDbClient $client
* @param string $table
- * @param integer $level
- * @param boolean $bubble
+ * @param int $level
+ * @param bool $bubble
*/
public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
{
- if (!defined('Aws\Common\Aws::VERSION') || version_compare('3.0', Aws::VERSION, '<=')) {
- throw new \RuntimeException('The DynamoDbHandler is only known to work with the AWS SDK 2.x releases');
+ if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) {
+ $this->version = 3;
+ $this->marshaler = new Marshaler;
+ } else {
+ $this->version = 2;
}
$this->client = $client;
@@ -60,11 +74,15 @@ public function __construct(DynamoDbClient $client, $table, $level = Logger::DEB
protected function write(array $record)
{
$filtered = $this->filterEmptyFields($record['formatted']);
- $formatted = $this->client->formatAttributes($filtered);
+ if ($this->version === 3) {
+ $formatted = $this->marshaler->marshalItem($filtered);
+ } else {
+ $formatted = $this->client->formatAttributes($filtered);
+ }
$this->client->putItem(array(
'TableName' => $this->table,
- 'Item' => $formatted
+ 'Item' => $formatted,
));
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
index 96e5d57..bb0f83e 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
@@ -46,10 +46,10 @@ class ElasticSearchHandler extends AbstractProcessingHandler
protected $options = array();
/**
- * @param Client $client Elastica Client object
- * @param array $options Handler configuration
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Client $client Elastica Client object
+ * @param array $options Handler configuration
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
index d1e1ee6..b2986b0 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
@@ -28,10 +28,10 @@ class ErrorLogHandler extends AbstractProcessingHandler
protected $expandNewlines;
/**
- * @param integer $messageType Says where the error should go.
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param Boolean $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
+ * @param int $messageType Says where the error should go.
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
*/
public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
index dad8227..938c1a7 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
@@ -31,7 +31,7 @@ class FilterHandler extends AbstractHandler
protected $handler;
/**
- * Minimum level for logs that are passes to handler
+ * Minimum level for logs that are passed to handler
*
* @var int[]
*/
@@ -40,7 +40,7 @@ class FilterHandler extends AbstractHandler
/**
* Whether the messages that are handled can bubble up the stack or not
*
- * @var Boolean
+ * @var bool
*/
protected $bubble;
@@ -48,7 +48,7 @@ class FilterHandler extends AbstractHandler
* @param callable|HandlerInterface $handler Handler or factory callable($record, $this).
* @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
* @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true)
{
@@ -70,8 +70,8 @@ public function getAcceptedLevels()
}
/**
- * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
- * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array
+ * @param int|string|array $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided
+ * @param int|string $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array
*/
public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
index c3e42ef..aaca12c 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
@@ -22,7 +22,7 @@ interface ActivationStrategyInterface
* Returns whether the given record activates the handler.
*
* @param array $record
- * @return Boolean
+ * @return bool
*/
public function isHandlerActivated(array $record);
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
index e3b403f..2a2a64d 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
@@ -2,12 +2,12 @@
/*
* This file is part of the Monolog package.
-*
-* (c) Jordi Boggiano
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code.
-*/
+ *
+ * (c) Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
namespace Monolog\Handler\FingersCrossed;
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
index 30a85dd..275fd51 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
@@ -14,6 +14,7 @@
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
use Monolog\Logger;
+use Monolog\ResettableInterface;
/**
* Buffers all records until a certain level is reached
@@ -41,8 +42,8 @@ class FingersCrossedHandler extends AbstractHandler
* @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler).
* @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true)
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true)
* @param int $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered
*/
public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true, $passthruLevel = null)
@@ -79,6 +80,26 @@ public function isHandling(array $record)
return true;
}
+ /**
+ * Manually activate this logger regardless of the activation strategy
+ */
+ public function activate()
+ {
+ if ($this->stopBuffering) {
+ $this->buffering = false;
+ }
+ if (!$this->handler instanceof HandlerInterface) {
+ $record = end($this->buffer) ?: null;
+
+ $this->handler = call_user_func($this->handler, $record, $this);
+ if (!$this->handler instanceof HandlerInterface) {
+ throw new \RuntimeException("The factory callable should return a HandlerInterface");
+ }
+ }
+ $this->handler->handleBatch($this->buffer);
+ $this->buffer = array();
+ }
+
/**
* {@inheritdoc}
*/
@@ -96,17 +117,7 @@ public function handle(array $record)
array_shift($this->buffer);
}
if ($this->activationStrategy->isHandlerActivated($record)) {
- if ($this->stopBuffering) {
- $this->buffering = false;
- }
- if (!$this->handler instanceof HandlerInterface) {
- $this->handler = call_user_func($this->handler, $record, $this);
- if (!$this->handler instanceof HandlerInterface) {
- throw new \RuntimeException("The factory callable should return a HandlerInterface");
- }
- }
- $this->handler->handleBatch($this->buffer);
- $this->buffer = array();
+ $this->activate();
}
} else {
$this->handler->handle($record);
@@ -120,24 +131,18 @@ public function handle(array $record)
*/
public function close()
{
- if (null !== $this->passthruLevel) {
- $level = $this->passthruLevel;
- $this->buffer = array_filter($this->buffer, function ($record) use ($level) {
- return $record['level'] >= $level;
- });
- if (count($this->buffer) > 0) {
- $this->handler->handleBatch($this->buffer);
- $this->buffer = array();
- }
- }
+ $this->flushBuffer();
}
- /**
- * Resets the state of the handler. Stops forwarding records to the wrapped handler.
- */
public function reset()
{
- $this->buffering = true;
+ $this->flushBuffer();
+
+ parent::reset();
+
+ if ($this->handler instanceof ResettableInterface) {
+ $this->handler->reset();
+ }
}
/**
@@ -150,4 +155,23 @@ public function clear()
$this->buffer = array();
$this->reset();
}
+
+ /**
+ * Resets the state of the handler. Stops forwarding records to the wrapped handler.
+ */
+ private function flushBuffer()
+ {
+ if (null !== $this->passthruLevel) {
+ $level = $this->passthruLevel;
+ $this->buffer = array_filter($this->buffer, function ($record) use ($level) {
+ return $record['level'] >= $level;
+ });
+ if (count($this->buffer) > 0) {
+ $this->handler->handleBatch($this->buffer);
+ }
+ }
+
+ $this->buffer = array();
+ $this->buffering = true;
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
index fee4795..c30b184 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
@@ -158,7 +158,7 @@ protected function write(array $record)
/**
* Verifies if the headers are accepted by the current user agent
*
- * @return Boolean
+ * @return bool
*/
protected function headersAccepted()
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php
index 388692c..c43c013 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php
@@ -118,7 +118,7 @@ private function buildHeader($content)
private function buildContent($record)
{
$dataArray = array(
- 'message' => $record['formatted']
+ 'message' => $record['formatted'],
);
return http_build_query($dataArray);
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php
new file mode 100644
index 0000000..3e2f1b2
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FormatterInterface;
+
+/**
+ * Interface to describe loggers that have a formatter
+ *
+ * This interface is present in monolog 1.x to ease forward compatibility.
+ *
+ * @author Jordi Boggiano
+ */
+interface FormattableHandlerInterface
+{
+ /**
+ * Sets the formatter.
+ *
+ * @param FormatterInterface $formatter
+ * @return HandlerInterface self
+ */
+ public function setFormatter(FormatterInterface $formatter): HandlerInterface;
+
+ /**
+ * Gets the formatter.
+ *
+ * @return FormatterInterface
+ */
+ public function getFormatter(): FormatterInterface;
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php b/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php
new file mode 100644
index 0000000..e9ec5e7
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php
@@ -0,0 +1,63 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Helper trait for implementing FormattableInterface
+ *
+ * This trait is present in monolog 1.x to ease forward compatibility.
+ *
+ * @author Jordi Boggiano
+ */
+trait FormattableHandlerTrait
+{
+ /**
+ * @var FormatterInterface
+ */
+ protected $formatter;
+
+ /**
+ * {@inheritdoc}
+ * @suppress PhanTypeMismatchReturn
+ */
+ public function setFormatter(FormatterInterface $formatter): HandlerInterface
+ {
+ $this->formatter = $formatter;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormatter(): FormatterInterface
+ {
+ if (!$this->formatter) {
+ $this->formatter = $this->getDefaultFormatter();
+ }
+
+ return $this->formatter;
+ }
+
+ /**
+ * Gets the default formatter.
+ *
+ * Overwrite this if the LineFormatter is not a good default for your handler.
+ */
+ protected function getDefaultFormatter(): FormatterInterface
+ {
+ return new LineFormatter();
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
index 28c7b55..71e4669 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
@@ -33,28 +33,20 @@ class GelfHandler extends AbstractProcessingHandler
/**
* @param PublisherInterface|IMessagePublisher|Publisher $publisher a publisher object
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($publisher, $level = Logger::DEBUG, $bubble = true)
{
parent::__construct($level, $bubble);
if (!$publisher instanceof Publisher && !$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) {
- throw new InvalidArgumentException("Invalid publisher, expected a Gelf\Publisher, Gelf\IMessagePublisher or Gelf\PublisherInterface instance");
+ throw new InvalidArgumentException('Invalid publisher, expected a Gelf\Publisher, Gelf\IMessagePublisher or Gelf\PublisherInterface instance');
}
$this->publisher = $publisher;
}
- /**
- * {@inheritdoc}
- */
- public function close()
- {
- $this->publisher = null;
- }
-
/**
* {@inheritdoc}
*/
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
index 99384d3..0d461f9 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
@@ -11,6 +11,9 @@
namespace Monolog\Handler;
+use Monolog\Formatter\FormatterInterface;
+use Monolog\ResettableInterface;
+
/**
* Forwards records to multiple handlers
*
@@ -21,8 +24,8 @@ class GroupHandler extends AbstractHandler
protected $handlers;
/**
- * @param array $handlers Array of Handlers.
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param array $handlers Array of Handlers.
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(array $handlers, $bubble = true)
{
@@ -73,8 +76,42 @@ public function handle(array $record)
*/
public function handleBatch(array $records)
{
+ if ($this->processors) {
+ $processed = array();
+ foreach ($records as $record) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ $processed[] = $record;
+ }
+ $records = $processed;
+ }
+
foreach ($this->handlers as $handler) {
$handler->handleBatch($records);
}
}
+
+ public function reset()
+ {
+ parent::reset();
+
+ foreach ($this->handlers as $handler) {
+ if ($handler instanceof ResettableInterface) {
+ $handler->reset();
+ }
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ foreach ($this->handlers as $handler) {
+ $handler->setFormatter($formatter);
+ }
+
+ return $this;
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
index d920c4b..8d5a4a0 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
@@ -31,7 +31,7 @@ interface HandlerInterface
*
* @param array $record Partial log record containing only a level key
*
- * @return Boolean
+ * @return bool
*/
public function isHandling(array $record);
@@ -46,7 +46,7 @@ public function isHandling(array $record);
* calling further handlers in the stack with a given log record.
*
* @param array $record The record to handle
- * @return Boolean true means that this handler handled the record, and that bubbling is not permitted.
+ * @return bool true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
*/
public function handle(array $record);
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php b/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php
new file mode 100644
index 0000000..55e6498
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php
@@ -0,0 +1,116 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\ResettableInterface;
+use Monolog\Formatter\FormatterInterface;
+
+/**
+ * This simple wrapper class can be used to extend handlers functionality.
+ *
+ * Example: A custom filtering that can be applied to any handler.
+ *
+ * Inherit from this class and override handle() like this:
+ *
+ * public function handle(array $record)
+ * {
+ * if ($record meets certain conditions) {
+ * return false;
+ * }
+ * return $this->handler->handle($record);
+ * }
+ *
+ * @author Alexey Karapetov
+ */
+class HandlerWrapper implements HandlerInterface, ResettableInterface
+{
+ /**
+ * @var HandlerInterface
+ */
+ protected $handler;
+
+ /**
+ * HandlerWrapper constructor.
+ * @param HandlerInterface $handler
+ */
+ public function __construct(HandlerInterface $handler)
+ {
+ $this->handler = $handler;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isHandling(array $record)
+ {
+ return $this->handler->isHandling($record);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ return $this->handler->handle($record);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ return $this->handler->handleBatch($records);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function pushProcessor($callback)
+ {
+ $this->handler->pushProcessor($callback);
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function popProcessor()
+ {
+ return $this->handler->popProcessor();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ $this->handler->setFormatter($formatter);
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormatter()
+ {
+ return $this->handler->getFormatter();
+ }
+
+ public function reset()
+ {
+ if ($this->handler instanceof ResettableInterface) {
+ return $this->handler->reset();
+ }
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
index 34d3437..179d626 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
@@ -84,19 +84,21 @@ class HipChatHandler extends SocketHandler
private $version;
/**
- * @param string $token HipChat API Token
- * @param string $room The room that should be alerted of the message (Id or Name)
- * @param string $name Name used in the "from" field. Not used for v2
- * @param bool $notify Trigger a notification in clients or not
- * @param int $level The minimum logging level at which this handler will be triggered
- * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
- * @param bool $useSSL Whether to connect via SSL.
- * @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
- * @param string $host The HipChat server hostname.
- * @param string $version The HipChat API version (default HipChatHandler::API_V1)
+ * @param string $token HipChat API Token
+ * @param string $room The room that should be alerted of the message (Id or Name)
+ * @param string $name Name used in the "from" field.
+ * @param bool $notify Trigger a notification in clients or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $useSSL Whether to connect via SSL.
+ * @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
+ * @param string $host The HipChat server hostname.
+ * @param string $version The HipChat API version (default HipChatHandler::API_V1)
*/
public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text', $host = 'api.hipchat.com', $version = self::API_V1)
{
+ @trigger_error('The Monolog\Handler\HipChatHandler class is deprecated. You should migrate to Slack and the SlackWebhookHandler / SlackbotHandler, see https://www.atlassian.com/partnerships/slack', E_USER_DEPRECATED);
+
if ($version == self::API_V1 && !$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) {
throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.');
}
@@ -143,10 +145,23 @@ private function buildContent($record)
'color' => $this->getAlertColor($record['level']),
);
+ if (!$this->validateStringLength($dataArray['message'], static::MAXIMUM_MESSAGE_LENGTH)) {
+ if (function_exists('mb_substr')) {
+ $dataArray['message'] = mb_substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
+ } else {
+ $dataArray['message'] = substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]';
+ }
+ }
+
// if we are using the legacy API then we need to send some additional information
if ($this->version == self::API_V1) {
$dataArray['room_id'] = $this->room;
- $dataArray['from'] = $this->name;
+ }
+
+ // append the sender name if it is set
+ // always append it if we use the v1 api (it is required in v1)
+ if ($this->version == self::API_V1 || $this->name !== null) {
+ $dataArray['from'] = (string) $this->name;
}
return http_build_query($dataArray);
@@ -179,7 +194,7 @@ private function buildHeader($content)
/**
* Assigns a color to each level of log records.
*
- * @param integer $level
+ * @param int $level
* @return string
*/
protected function getAlertColor($level)
@@ -206,6 +221,21 @@ protected function getAlertColor($level)
protected function write(array $record)
{
parent::write($record);
+ $this->finalizeWrite();
+ }
+
+ /**
+ * Finalizes the request by reading some bytes and then closing the socket
+ *
+ * If we do not read some but close the socket too early, hipchat sometimes
+ * drops the request entirely.
+ */
+ protected function finalizeWrite()
+ {
+ $res = $this->getResource();
+ if (is_resource($res)) {
+ @fread($res, 2048);
+ }
$this->closeSocket();
}
@@ -303,7 +333,7 @@ private function combineRecords($records)
array(
'level' => $level,
'level_name' => $levelName,
- 'datetime' => $datetime
+ 'datetime' => $datetime,
)
);
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php
index bc11705..7f22622 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php
@@ -30,10 +30,10 @@ class IFTTTHandler extends AbstractProcessingHandler
private $secretKey;
/**
- * @param string $eventName The name of the IFTTT Maker event that should be triggered
- * @param string $secretKey A valid IFTTT secret key
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param string $eventName The name of the IFTTT Maker event that should be triggered
+ * @param string $secretKey A valid IFTTT secret key
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true)
{
@@ -51,7 +51,7 @@ public function write(array $record)
$postData = array(
"value1" => $record["channel"],
"value2" => $record["level_name"],
- "value3" => $record["message"]
+ "value3" => $record["message"],
);
$postString = json_encode($postData);
@@ -61,7 +61,7 @@ public function write(array $record)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- "Content-Type: application/json"
+ "Content-Type: application/json",
));
Curl\Util::execute($ch);
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php
new file mode 100644
index 0000000..8f683dc
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php
@@ -0,0 +1,62 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+ namespace Monolog\Handler;
+
+ use Monolog\Logger;
+
+/**
+ * Inspired on LogEntriesHandler.
+ *
+ * @author Robert Kaufmann III
+ * @author Gabriel Machado
+ */
+class InsightOpsHandler extends SocketHandler
+{
+ /**
+ * @var string
+ */
+ protected $logToken;
+
+ /**
+ * @param string $token Log token supplied by InsightOps
+ * @param string $region Region where InsightOps account is hosted. Could be 'us' or 'eu'.
+ * @param bool $useSSL Whether or not SSL encryption should be used
+ * @param int $level The minimum logging level to trigger this handler
+ * @param bool $bubble Whether or not messages that are handled should bubble up the stack.
+ *
+ * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
+ */
+ public function __construct($token, $region = 'us', $useSSL = true, $level = Logger::DEBUG, $bubble = true)
+ {
+ if ($useSSL && !extension_loaded('openssl')) {
+ throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for InsightOpsHandler');
+ }
+
+ $endpoint = $useSSL
+ ? 'ssl://' . $region . '.data.logs.insight.rapid7.com:443'
+ : $region . '.data.logs.insight.rapid7.com:80';
+
+ parent::__construct($endpoint, $level, $bubble);
+ $this->logToken = $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ * @return string
+ */
+ protected function generateDataStream($record)
+ {
+ return $this->logToken . ' ' . $record['formatted'];
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
index bd56230..ea89fb3 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
@@ -24,20 +24,20 @@ class LogEntriesHandler extends SocketHandler
protected $logToken;
/**
- * @param string $token Log token supplied by LogEntries
- * @param boolean $useSSL Whether or not SSL encryption should be used.
- * @param int $level The minimum logging level to trigger this handler
- * @param boolean $bubble Whether or not messages that are handled should bubble up the stack.
+ * @param string $token Log token supplied by LogEntries
+ * @param bool $useSSL Whether or not SSL encryption should be used.
+ * @param int $level The minimum logging level to trigger this handler
+ * @param bool $bubble Whether or not messages that are handled should bubble up the stack.
*
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
*/
- public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true)
+ public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true, $host = 'data.logentries.com')
{
if ($useSSL && !extension_loaded('openssl')) {
throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
}
- $endpoint = $useSSL ? 'ssl://data.logentries.com:443' : 'data.logentries.com:80';
+ $endpoint = $useSSL ? 'ssl://' . $host . ':443' : $host . ':80';
parent::__construct($endpoint, $level, $bubble);
$this->logToken = $token;
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
index 50ed638..9e23283 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
@@ -52,4 +52,16 @@ protected function write(array $record)
{
$this->send((string) $record['formatted'], array($record));
}
+
+ protected function getHighestRecord(array $records)
+ {
+ $highestRecord = null;
+ foreach ($records as $record) {
+ if ($highestRecord === null || $highestRecord['level'] < $record['level']) {
+ $highestRecord = $record;
+ }
+ }
+
+ return $highestRecord;
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php
index 0ed098a..3f0956a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php
@@ -26,8 +26,8 @@ class MandrillHandler extends MailHandler
/**
* @param string $apiKey A valid Mandrill API key
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($apiKey, $message, $level = Logger::ERROR, $bubble = true)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
index 6c431f2..56fe755 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
@@ -31,8 +31,8 @@ class MongoDBHandler extends AbstractProcessingHandler
public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
{
- if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
- throw new \InvalidArgumentException('MongoClient or Mongo instance required');
+ if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) {
+ throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB\Client instance required');
}
$this->mongoCollection = $mongo->selectCollection($database, $collection);
@@ -42,7 +42,11 @@ public function __construct($mongo, $database, $collection, $level = Logger::DEB
protected function write(array $record)
{
- $this->mongoCollection->save($record["formatted"]);
+ if ($this->mongoCollection instanceof \MongoDB\Collection) {
+ $this->mongoCollection->insertOne($record["formatted"]);
+ } else {
+ $this->mongoCollection->save($record["formatted"]);
+ }
}
/**
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
index 5118a0e..d7807fd 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
/**
* NativeMailerHandler uses the mail() function to send the emails
@@ -47,7 +48,7 @@ class NativeMailerHandler extends MailHandler
/**
* The wordwrap length for the message
- * @var integer
+ * @var int
*/
protected $maxColumnWidth;
@@ -67,8 +68,8 @@ class NativeMailerHandler extends MailHandler
* @param string|array $to The receiver of the mail
* @param string $subject The subject of the mail
* @param string $from The sender of the mail
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int $maxColumnWidth The maximum column width that the message lines will have
*/
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
@@ -101,7 +102,7 @@ public function addHeader($headers)
/**
* Add parameters to the message
*
- * @param string|array $parameters Custom added parameters
+ * @param string|array $parameters Custom added parameters
* @return self
*/
public function addParameter($parameters)
@@ -122,8 +123,16 @@ protected function send($content, array $records)
if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) {
$headers .= 'MIME-Version: 1.0' . "\r\n";
}
+
+ $subject = $this->subject;
+ if ($records) {
+ $subjectFormatter = new LineFormatter($this->subject);
+ $subject = $subjectFormatter->format($this->getHighestRecord($records));
+ }
+
+ $parameters = implode(' ', $this->parameters);
foreach ($this->to as $to) {
- mail($to, $this->subject, $content, $headers, implode(' ', $this->parameters));
+ mail($to, $subject, $content, $headers, $parameters);
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
index 8cb4ab3..f911997 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
@@ -18,6 +18,8 @@
* Class to record a log on a NewRelic application.
* Enabling New Relic High Security mode may prevent capture of useful information.
*
+ * This handler requires a NormalizerFormatter to function and expects an array in $record['formatted']
+ *
* @see https://docs.newrelic.com/docs/agents/php-agent
* @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security
*/
@@ -41,16 +43,16 @@ class NewRelicHandler extends AbstractProcessingHandler
* Some context and extra data is passed into the handler as arrays of values. Do we send them as is
* (useful if we are using the API), or explode them for display on the NewRelic RPM website?
*
- * @var boolean
+ * @var bool
*/
protected $explodeArrays;
/**
* {@inheritDoc}
*
- * @param string $appName
- * @param boolean $explodeArrays
- * @param string $transactionName
+ * @param string $appName
+ * @param bool $explodeArrays
+ * @param string $transactionName
*/
public function __construct(
$level = Logger::ERROR,
@@ -84,30 +86,34 @@ protected function write(array $record)
unset($record['formatted']['context']['transaction_name']);
}
- if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
+ if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) {
newrelic_notice_error($record['message'], $record['context']['exception']);
unset($record['formatted']['context']['exception']);
} else {
newrelic_notice_error($record['message']);
}
- foreach ($record['formatted']['context'] as $key => $parameter) {
- if (is_array($parameter) && $this->explodeArrays) {
- foreach ($parameter as $paramKey => $paramValue) {
- $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue);
+ if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) {
+ foreach ($record['formatted']['context'] as $key => $parameter) {
+ if (is_array($parameter) && $this->explodeArrays) {
+ foreach ($parameter as $paramKey => $paramValue) {
+ $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue);
+ }
+ } else {
+ $this->setNewRelicParameter('context_' . $key, $parameter);
}
- } else {
- $this->setNewRelicParameter('context_' . $key, $parameter);
}
}
- foreach ($record['formatted']['extra'] as $key => $parameter) {
- if (is_array($parameter) && $this->explodeArrays) {
- foreach ($parameter as $paramKey => $paramValue) {
- $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue);
+ if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) {
+ foreach ($record['formatted']['extra'] as $key => $parameter) {
+ if (is_array($parameter) && $this->explodeArrays) {
+ foreach ($parameter as $paramKey => $paramValue) {
+ $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue);
+ }
+ } else {
+ $this->setNewRelicParameter('extra_' . $key, $parameter);
}
- } else {
- $this->setNewRelicParameter('extra_' . $key, $parameter);
}
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
index 3754e45..4b84588 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
@@ -24,7 +24,7 @@
class NullHandler extends AbstractHandler
{
/**
- * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param int $level The minimum logging level at which this handler will be triggered
*/
public function __construct($level = Logger::DEBUG)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php
index 2b7e353..1f2076a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php
@@ -66,10 +66,10 @@ class PHPConsoleHandler extends AbstractProcessingHandler
private $connector;
/**
- * @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details
- * @param Connector|null $connector Instance of \PhpConsole\Connector class (optional)
- * @param int $level
- * @param bool $bubble
+ * @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details
+ * @param Connector|null $connector Instance of \PhpConsole\Connector class (optional)
+ * @param int $level
+ * @param bool $bubble
* @throws Exception
*/
public function __construct(array $options = array(), Connector $connector = null, $level = Logger::DEBUG, $bubble = true)
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php
new file mode 100644
index 0000000..66a3d83
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Processor\ProcessorInterface;
+
+/**
+ * Interface to describe loggers that have processors
+ *
+ * This interface is present in monolog 1.x to ease forward compatibility.
+ *
+ * @author Jordi Boggiano
+ */
+interface ProcessableHandlerInterface
+{
+ /**
+ * Adds a processor in the stack.
+ *
+ * @param ProcessorInterface|callable $callback
+ * @return HandlerInterface self
+ */
+ public function pushProcessor($callback): HandlerInterface;
+
+ /**
+ * Removes the processor on top of the stack and returns it.
+ *
+ * @throws \LogicException In case the processor stack is empty
+ * @return callable
+ */
+ public function popProcessor(): callable;
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php
new file mode 100644
index 0000000..09f32a1
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php
@@ -0,0 +1,73 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\ResettableInterface;
+
+/**
+ * Helper trait for implementing ProcessableInterface
+ *
+ * This trait is present in monolog 1.x to ease forward compatibility.
+ *
+ * @author Jordi Boggiano
+ */
+trait ProcessableHandlerTrait
+{
+ /**
+ * @var callable[]
+ */
+ protected $processors = [];
+
+ /**
+ * {@inheritdoc}
+ * @suppress PhanTypeMismatchReturn
+ */
+ public function pushProcessor($callback): HandlerInterface
+ {
+ array_unshift($this->processors, $callback);
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function popProcessor(): callable
+ {
+ if (!$this->processors) {
+ throw new \LogicException('You tried to pop from an empty processor stack.');
+ }
+
+ return array_shift($this->processors);
+ }
+
+ /**
+ * Processes a record.
+ */
+ protected function processRecord(array $record): array
+ {
+ foreach ($this->processors as $processor) {
+ $record = $processor($record);
+ }
+
+ return $record;
+ }
+
+ protected function resetProcessors(): void
+ {
+ foreach ($this->processors as $processor) {
+ if ($processor instanceof ResettableInterface) {
+ $processor->reset();
+ }
+ }
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php
index 1ae8584..a99e6ab 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php
@@ -31,7 +31,7 @@ class PsrHandler extends AbstractHandler
/**
* @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied
* @param int $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, $bubble = true)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
index 9917b64..f27bb3d 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
@@ -68,16 +68,16 @@ class PushoverHandler extends SocketHandler
* @param string $token Pushover api token
* @param string|array $users Pushover user id or array of ids the message will be sent to
* @param string $title Title sent to the Pushover API
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not
* the pushover.net app owner. OpenSSL is required for this option.
- * @param integer $highPriorityLevel The minimum logging level at which this handler will start
+ * @param int $highPriorityLevel The minimum logging level at which this handler will start
* sending "high priority" requests to the Pushover API
- * @param integer $emergencyLevel The minimum logging level at which this handler will start
+ * @param int $emergencyLevel The minimum logging level at which this handler will start
* sending "emergency" requests to the Pushover API
- * @param integer $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user.
- * @param integer $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds).
+ * @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user.
+ * @param int $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds).
*/
public function __construct($token, $users, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $highPriorityLevel = Logger::CRITICAL, $emergencyLevel = Logger::EMERGENCY, $retry = 30, $expire = 25200)
{
@@ -115,7 +115,7 @@ private function buildContent($record)
'user' => $this->user,
'message' => $message,
'title' => $this->title,
- 'timestamp' => $timestamp
+ 'timestamp' => $timestamp,
);
if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) {
@@ -176,10 +176,10 @@ public function setEmergencyLevel($value)
/**
* Use the formatted message?
- * @param boolean $value
+ * @param bool $value
*/
public function useFormattedMessage($value)
{
- $this->useFormattedMessage = (boolean) $value;
+ $this->useFormattedMessage = (bool) $value;
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
index 1807705..1929f25 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
@@ -18,7 +18,7 @@
/**
* Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server
- * using raven-php (https://github.com/getsentry/raven-php)
+ * using sentry-php (https://github.com/getsentry/sentry-php)
*
* @author Marc Abramowitz
*/
@@ -27,7 +27,7 @@ class RavenHandler extends AbstractProcessingHandler
/**
* Translates Monolog log levels to Raven log levels.
*/
- private $logLevels = array(
+ protected $logLevels = array(
Logger::DEBUG => Raven_Client::DEBUG,
Logger::INFO => Raven_Client::INFO,
Logger::NOTICE => Raven_Client::INFO,
@@ -38,6 +38,12 @@ class RavenHandler extends AbstractProcessingHandler
Logger::EMERGENCY => Raven_Client::FATAL,
);
+ /**
+ * @var string should represent the current version of the calling
+ * software. Can be any string (git commit, version number)
+ */
+ protected $release;
+
/**
* @var Raven_Client the client object that sends the message to the server
*/
@@ -50,11 +56,13 @@ class RavenHandler extends AbstractProcessingHandler
/**
* @param Raven_Client $ravenClient
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true)
{
+ @trigger_error('The Monolog\Handler\RavenHandler class is deprecated. You should rather upgrade to the sentry/sentry 2.x and use Sentry\Monolog\Handler, see https://github.com/getsentry/sentry-php/blob/master/src/Monolog/Handler.php', E_USER_DEPRECATED);
+
parent::__construct($level, $bubble);
$this->ravenClient = $ravenClient;
@@ -78,7 +86,7 @@ public function handleBatch(array $records)
// the record with the highest severity is the "main" one
$record = array_reduce($records, function ($highest, $record) {
- if ($record['level'] >= $highest['level']) {
+ if ($record['level'] > $highest['level']) {
return $record;
}
@@ -139,6 +147,10 @@ protected function write(array $record)
$options['tags'] = array_merge($options['tags'], $record['context']['tags']);
unset($record['context']['tags']);
}
+ if (!empty($record['context']['fingerprint'])) {
+ $options['fingerprint'] = $record['context']['fingerprint'];
+ unset($record['context']['fingerprint']);
+ }
if (!empty($record['context']['logger'])) {
$options['logger'] = $record['context']['logger'];
unset($record['context']['logger']);
@@ -165,8 +177,12 @@ protected function write(array $record)
$options['extra']['extra'] = $record['extra'];
}
- if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
- $options['extra']['message'] = $record['formatted'];
+ if (!empty($this->release) && !isset($options['release'])) {
+ $options['release'] = $this->release;
+ }
+
+ if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) {
+ $options['message'] = $record['formatted'];
$this->ravenClient->captureException($record['context']['exception'], $options);
} else {
$this->ravenClient->captureMessage($record['formatted'], array(), $options);
@@ -202,6 +218,17 @@ protected function getDefaultBatchFormatter()
*/
protected function getExtraParameters()
{
- return array('checksum', 'release');
+ return array('contexts', 'checksum', 'release', 'event_id');
+ }
+
+ /**
+ * @param string $value
+ * @return self
+ */
+ public function setRelease($value)
+ {
+ $this->release = $value;
+
+ return $this;
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
index 157e2f9..590f996 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
@@ -34,9 +34,9 @@ class RedisHandler extends AbstractProcessingHandler
/**
* @param \Predis\Client|\Redis $redis The redis instance
* @param string $key The key name to push records to
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param integer $capSize Number of entries to limit list size to
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $capSize Number of entries to limit list size to
*/
public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false)
{
@@ -67,7 +67,7 @@ protected function write(array $record)
* Write and cap the collection
* Writes the record to the redis list and caps its
*
- * @param array $record associative record array
+ * @param array $record associative record array
* @return void
*/
protected function writeCapped(array $record)
@@ -76,7 +76,7 @@ protected function writeCapped(array $record)
$this->redisClient->multi()
->rpush($this->redisKey, $record["formatted"])
->ltrim($this->redisKey, -$this->capSize, -1)
- ->execute();
+ ->exec();
} else {
$redisKey = $this->redisKey;
$capSize = $this->capSize;
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
index 0ad618d..65073ff 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
@@ -18,6 +18,17 @@
/**
* Sends errors to Rollbar
*
+ * If the context data contains a `payload` key, that is used as an array
+ * of payload options to RollbarNotifier's report_message/report_exception methods.
+ *
+ * Rollbar's context info will contain the context + extra keys from the log record
+ * merged, and then on top of that a few keys:
+ *
+ * - level (rollbar level name)
+ * - monolog_level (monolog level name, raw level, as rollbar only has 5 but monolog 8)
+ * - channel
+ * - datetime (unix timestamp)
+ *
* @author Paul Statezny
*/
class RollbarHandler extends AbstractProcessingHandler
@@ -29,6 +40,17 @@ class RollbarHandler extends AbstractProcessingHandler
*/
protected $rollbarNotifier;
+ protected $levelMap = array(
+ Logger::DEBUG => 'debug',
+ Logger::INFO => 'info',
+ Logger::NOTICE => 'info',
+ Logger::WARNING => 'warning',
+ Logger::ERROR => 'error',
+ Logger::CRITICAL => 'critical',
+ Logger::ALERT => 'critical',
+ Logger::EMERGENCY => 'critical',
+ );
+
/**
* Records whether any log records have been added since the last flush of the rollbar notifier
*
@@ -36,10 +58,12 @@ class RollbarHandler extends AbstractProcessingHandler
*/
private $hasRecords = false;
+ protected $initialized = false;
+
/**
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
{
@@ -53,43 +77,68 @@ public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::E
*/
protected function write(array $record)
{
- if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
- $context = $record['context'];
+ if (!$this->initialized) {
+ // __destructor() doesn't get called on Fatal errors
+ register_shutdown_function(array($this, 'close'));
+ $this->initialized = true;
+ }
+
+ $context = $record['context'];
+ $payload = array();
+ if (isset($context['payload'])) {
+ $payload = $context['payload'];
+ unset($context['payload']);
+ }
+ $context = array_merge($context, $record['extra'], array(
+ 'level' => $this->levelMap[$record['level']],
+ 'monolog_level' => $record['level_name'],
+ 'channel' => $record['channel'],
+ 'datetime' => $record['datetime']->format('U'),
+ ));
+
+ if (isset($context['exception']) && $context['exception'] instanceof Exception) {
+ $payload['level'] = $context['level'];
$exception = $context['exception'];
unset($context['exception']);
- $payload = array();
- if (isset($context['payload'])) {
- $payload = $context['payload'];
- unset($context['payload']);
- }
-
$this->rollbarNotifier->report_exception($exception, $context, $payload);
} else {
- $extraData = array(
- 'level' => $record['level'],
- 'channel' => $record['channel'],
- 'datetime' => $record['datetime']->format('U'),
- );
-
$this->rollbarNotifier->report_message(
$record['message'],
- $record['level_name'],
- array_merge($record['context'], $record['extra'], $extraData)
+ $context['level'],
+ $context,
+ $payload
);
}
$this->hasRecords = true;
}
- /**
- * {@inheritdoc}
- */
- public function close()
+ public function flush()
{
if ($this->hasRecords) {
$this->rollbarNotifier->flush();
$this->hasRecords = false;
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $this->flush();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function reset()
+ {
+ $this->flush();
+
+ parent::reset();
+ }
+
+
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
index 0a20377..ae2309f 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
@@ -24,6 +24,10 @@
*/
class RotatingFileHandler extends StreamHandler
{
+ const FILE_PER_DAY = 'Y-m-d';
+ const FILE_PER_MONTH = 'Y-m';
+ const FILE_PER_YEAR = 'Y';
+
protected $filename;
protected $maxFiles;
protected $mustRotate;
@@ -33,11 +37,11 @@ class RotatingFileHandler extends StreamHandler
/**
* @param string $filename
- * @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $maxFiles The maximal amount of files to keep (0 means unlimited)
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
- * @param Boolean $useLocking Try to lock log file before doing any writes
+ * @param bool $useLocking Try to lock log file before doing any writes
*/
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false)
{
@@ -62,8 +66,35 @@ public function close()
}
}
+ /**
+ * {@inheritdoc}
+ */
+ public function reset()
+ {
+ parent::reset();
+
+ if (true === $this->mustRotate) {
+ $this->rotate();
+ }
+ }
+
public function setFilenameFormat($filenameFormat, $dateFormat)
{
+ if (!preg_match('{^Y(([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) {
+ trigger_error(
+ 'Invalid date format - format must be one of '.
+ 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") '.
+ 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '.
+ 'date formats using slashes, underscores and/or dots instead of dashes.',
+ E_USER_DEPRECATED
+ );
+ }
+ if (substr_count($filenameFormat, '{date}') === 0) {
+ trigger_error(
+ 'Invalid filename format - format should contain at least `{date}`, because otherwise rotating is impossible.',
+ E_USER_DEPRECATED
+ );
+ }
$this->filenameFormat = $filenameFormat;
$this->dateFormat = $dateFormat;
$this->url = $this->getTimedFilename();
@@ -115,7 +146,11 @@ protected function rotate()
foreach (array_slice($logFiles, $this->maxFiles) as $file) {
if (is_writable($file)) {
+ // suppress errors here as unlink() might fail if two processes
+ // are cleaning up/rotating at the same time
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {});
unlink($file);
+ restore_error_handler();
}
}
@@ -143,7 +178,7 @@ protected function getGlobPattern()
$fileInfo = pathinfo($this->filename);
$glob = str_replace(
array('{filename}', '{date}'),
- array($fileInfo['filename'], '*'),
+ array($fileInfo['filename'], '[0-9][0-9][0-9][0-9]*'),
$fileInfo['dirname'] . '/' . $this->filenameFormat
);
if (!empty($fileInfo['extension'])) {
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php b/application/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php
new file mode 100644
index 0000000..e55e0e2
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php
@@ -0,0 +1,294 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler\Slack;
+
+use Monolog\Logger;
+use Monolog\Formatter\NormalizerFormatter;
+use Monolog\Formatter\FormatterInterface;
+
+/**
+ * Slack record utility helping to log to Slack webhooks or API.
+ *
+ * @author Greg Kedzierski
+ * @author Haralan Dobrev
+ * @see https://api.slack.com/incoming-webhooks
+ * @see https://api.slack.com/docs/message-attachments
+ */
+class SlackRecord
+{
+ const COLOR_DANGER = 'danger';
+
+ const COLOR_WARNING = 'warning';
+
+ const COLOR_GOOD = 'good';
+
+ const COLOR_DEFAULT = '#e3e4e6';
+
+ /**
+ * Slack channel (encoded ID or name)
+ * @var string|null
+ */
+ private $channel;
+
+ /**
+ * Name of a bot
+ * @var string|null
+ */
+ private $username;
+
+ /**
+ * User icon e.g. 'ghost', 'http://example.com/user.png'
+ * @var string
+ */
+ private $userIcon;
+
+ /**
+ * Whether the message should be added to Slack as attachment (plain text otherwise)
+ * @var bool
+ */
+ private $useAttachment;
+
+ /**
+ * Whether the the context/extra messages added to Slack as attachments are in a short style
+ * @var bool
+ */
+ private $useShortAttachment;
+
+ /**
+ * Whether the attachment should include context and extra data
+ * @var bool
+ */
+ private $includeContextAndExtra;
+
+ /**
+ * Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
+ * @var array
+ */
+ private $excludeFields;
+
+ /**
+ * @var FormatterInterface
+ */
+ private $formatter;
+
+ /**
+ * @var NormalizerFormatter
+ */
+ private $normalizerFormatter;
+
+ public function __construct($channel = null, $username = null, $useAttachment = true, $userIcon = null, $useShortAttachment = false, $includeContextAndExtra = false, array $excludeFields = array(), FormatterInterface $formatter = null)
+ {
+ $this->channel = $channel;
+ $this->username = $username;
+ $this->userIcon = trim($userIcon, ':');
+ $this->useAttachment = $useAttachment;
+ $this->useShortAttachment = $useShortAttachment;
+ $this->includeContextAndExtra = $includeContextAndExtra;
+ $this->excludeFields = $excludeFields;
+ $this->formatter = $formatter;
+
+ if ($this->includeContextAndExtra) {
+ $this->normalizerFormatter = new NormalizerFormatter();
+ }
+ }
+
+ public function getSlackData(array $record)
+ {
+ $dataArray = array();
+ $record = $this->excludeFields($record);
+
+ if ($this->username) {
+ $dataArray['username'] = $this->username;
+ }
+
+ if ($this->channel) {
+ $dataArray['channel'] = $this->channel;
+ }
+
+ if ($this->formatter && !$this->useAttachment) {
+ $message = $this->formatter->format($record);
+ } else {
+ $message = $record['message'];
+ }
+
+ if ($this->useAttachment) {
+ $attachment = array(
+ 'fallback' => $message,
+ 'text' => $message,
+ 'color' => $this->getAttachmentColor($record['level']),
+ 'fields' => array(),
+ 'mrkdwn_in' => array('fields'),
+ 'ts' => $record['datetime']->getTimestamp()
+ );
+
+ if ($this->useShortAttachment) {
+ $attachment['title'] = $record['level_name'];
+ } else {
+ $attachment['title'] = 'Message';
+ $attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name']);
+ }
+
+
+ if ($this->includeContextAndExtra) {
+ foreach (array('extra', 'context') as $key) {
+ if (empty($record[$key])) {
+ continue;
+ }
+
+ if ($this->useShortAttachment) {
+ $attachment['fields'][] = $this->generateAttachmentField(
+ $key,
+ $record[$key]
+ );
+ } else {
+ // Add all extra fields as individual fields in attachment
+ $attachment['fields'] = array_merge(
+ $attachment['fields'],
+ $this->generateAttachmentFields($record[$key])
+ );
+ }
+ }
+ }
+
+ $dataArray['attachments'] = array($attachment);
+ } else {
+ $dataArray['text'] = $message;
+ }
+
+ if ($this->userIcon) {
+ if (filter_var($this->userIcon, FILTER_VALIDATE_URL)) {
+ $dataArray['icon_url'] = $this->userIcon;
+ } else {
+ $dataArray['icon_emoji'] = ":{$this->userIcon}:";
+ }
+ }
+
+ return $dataArray;
+ }
+
+ /**
+ * Returned a Slack message attachment color associated with
+ * provided level.
+ *
+ * @param int $level
+ * @return string
+ */
+ public function getAttachmentColor($level)
+ {
+ switch (true) {
+ case $level >= Logger::ERROR:
+ return self::COLOR_DANGER;
+ case $level >= Logger::WARNING:
+ return self::COLOR_WARNING;
+ case $level >= Logger::INFO:
+ return self::COLOR_GOOD;
+ default:
+ return self::COLOR_DEFAULT;
+ }
+ }
+
+ /**
+ * Stringifies an array of key/value pairs to be used in attachment fields
+ *
+ * @param array $fields
+ *
+ * @return string
+ */
+ public function stringify($fields)
+ {
+ $normalized = $this->normalizerFormatter->format($fields);
+ $prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;
+
+ $hasSecondDimension = count(array_filter($normalized, 'is_array'));
+ $hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));
+
+ return $hasSecondDimension || $hasNonNumericKeys
+ ? json_encode($normalized, $prettyPrintFlag)
+ : json_encode($normalized);
+ }
+
+ /**
+ * Sets the formatter
+ *
+ * @param FormatterInterface $formatter
+ */
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ $this->formatter = $formatter;
+ }
+
+ /**
+ * Generates attachment field
+ *
+ * @param string $title
+ * @param string|array $value
+ *
+ * @return array
+ */
+ private function generateAttachmentField($title, $value)
+ {
+ $value = is_array($value)
+ ? sprintf('```%s```', $this->stringify($value))
+ : $value;
+
+ return array(
+ 'title' => ucfirst($title),
+ 'value' => $value,
+ 'short' => false
+ );
+ }
+
+ /**
+ * Generates a collection of attachment fields from array
+ *
+ * @param array $data
+ *
+ * @return array
+ */
+ private function generateAttachmentFields(array $data)
+ {
+ $fields = array();
+ foreach ($this->normalizerFormatter->format($data) as $key => $value) {
+ $fields[] = $this->generateAttachmentField($key, $value);
+ }
+
+ return $fields;
+ }
+
+ /**
+ * Get a copy of record with fields excluded according to $this->excludeFields
+ *
+ * @param array $record
+ *
+ * @return array
+ */
+ private function excludeFields(array $record)
+ {
+ foreach ($this->excludeFields as $field) {
+ $keys = explode('.', $field);
+ $node = &$record;
+ $lastKey = end($keys);
+ foreach ($keys as $key) {
+ if (!isset($node[$key])) {
+ break;
+ }
+ if ($lastKey === $key) {
+ unset($node[$key]);
+ break;
+ }
+ $node = &$node[$key];
+ }
+ }
+
+ return $record;
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php
index 61245ff..45d634f 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php
@@ -11,8 +11,9 @@
namespace Monolog\Handler;
+use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;
-use Monolog\Formatter\LineFormatter;
+use Monolog\Handler\Slack\SlackRecord;
/**
* Sends notifications through Slack API
@@ -29,58 +30,25 @@ class SlackHandler extends SocketHandler
private $token;
/**
- * Slack channel (encoded ID or name)
- * @var string
- */
- private $channel;
-
- /**
- * Name of a bot
- * @var string
- */
- private $username;
-
- /**
- * Emoji icon name
- * @var string
- */
- private $iconEmoji;
-
- /**
- * Whether the message should be added to Slack as attachment (plain text otherwise)
- * @var bool
- */
- private $useAttachment;
-
- /**
- * Whether the the context/extra messages added to Slack as attachments are in a short style
- * @var bool
- */
- private $useShortAttachment;
-
- /**
- * Whether the attachment should include context and extra data
- * @var bool
- */
- private $includeContextAndExtra;
-
- /**
- * @var LineFormatter
+ * Instance of the SlackRecord util class preparing data for Slack API.
+ * @var SlackRecord
*/
- private $lineFormatter;
+ private $slackRecord;
/**
- * @param string $token Slack API token
- * @param string $channel Slack channel (encoded ID or name)
- * @param string $username Name of a bot
- * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
- * @param string|null $iconEmoji The emoji name to use (or null)
- * @param int $level The minimum logging level at which this handler will be triggered
- * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
- * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
- * @param bool $includeContextAndExtra Whether the attachment should include context and extra data
+ * @param string $token Slack API token
+ * @param string $channel Slack channel (encoded ID or name)
+ * @param string|null $username Name of a bot
+ * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
+ * @param string|null $iconEmoji The emoji name to use (or null)
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
+ * @param bool $includeContextAndExtra Whether the attachment should include context and extra data
+ * @param array $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
+ * @throws MissingExtensionException If no OpenSSL PHP extension configured
*/
- public function __construct($token, $channel, $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $level = Logger::CRITICAL, $bubble = true, $useShortAttachment = false, $includeContextAndExtra = false)
+ public function __construct($token, $channel, $username = null, $useAttachment = true, $iconEmoji = null, $level = Logger::CRITICAL, $bubble = true, $useShortAttachment = false, $includeContextAndExtra = false, array $excludeFields = array())
{
if (!extension_loaded('openssl')) {
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
@@ -88,16 +56,28 @@ public function __construct($token, $channel, $username = 'Monolog', $useAttachm
parent::__construct('ssl://slack.com:443', $level, $bubble);
+ $this->slackRecord = new SlackRecord(
+ $channel,
+ $username,
+ $useAttachment,
+ $iconEmoji,
+ $useShortAttachment,
+ $includeContextAndExtra,
+ $excludeFields,
+ $this->formatter
+ );
+
$this->token = $token;
- $this->channel = $channel;
- $this->username = $username;
- $this->iconEmoji = trim($iconEmoji, ':');
- $this->useAttachment = $useAttachment;
- $this->useShortAttachment = $useShortAttachment;
- $this->includeContextAndExtra = $includeContextAndExtra;
- if ($this->includeContextAndExtra) {
- $this->lineFormatter = new LineFormatter;
- }
+ }
+
+ public function getSlackRecord()
+ {
+ return $this->slackRecord;
+ }
+
+ public function getToken()
+ {
+ return $this->token;
}
/**
@@ -134,81 +114,11 @@ private function buildContent($record)
*/
protected function prepareContentData($record)
{
- $dataArray = array(
- 'token' => $this->token,
- 'channel' => $this->channel,
- 'username' => $this->username,
- 'text' => '',
- 'attachments' => array()
- );
-
- if ($this->useAttachment) {
- $attachment = array(
- 'fallback' => $record['message'],
- 'color' => $this->getAttachmentColor($record['level']),
- 'fields' => array()
- );
-
- if ($this->useShortAttachment) {
- $attachment['title'] = $record['level_name'];
- $attachment['text'] = $record['message'];
- } else {
- $attachment['title'] = 'Message';
- $attachment['text'] = $record['message'];
- $attachment['fields'][] = array(
- 'title' => 'Level',
- 'value' => $record['level_name'],
- 'short' => true
- );
- }
-
- if ($this->includeContextAndExtra) {
- if (!empty($record['extra'])) {
- if ($this->useShortAttachment) {
- $attachment['fields'][] = array(
- 'title' => "Extra",
- 'value' => $this->stringify($record['extra']),
- 'short' => $this->useShortAttachment
- );
- } else {
- // Add all extra fields as individual fields in attachment
- foreach ($record['extra'] as $var => $val) {
- $attachment['fields'][] = array(
- 'title' => $var,
- 'value' => $val,
- 'short' => $this->useShortAttachment
- );
- }
- }
- }
-
- if (!empty($record['context'])) {
- if ($this->useShortAttachment) {
- $attachment['fields'][] = array(
- 'title' => "Context",
- 'value' => $this->stringify($record['context']),
- 'short' => $this->useShortAttachment
- );
- } else {
- // Add all context fields as individual fields in attachment
- foreach ($record['context'] as $var => $val) {
- $attachment['fields'][] = array(
- 'title' => $var,
- 'value' => $val,
- 'short' => $this->useShortAttachment
- );
- }
- }
- }
- }
+ $dataArray = $this->slackRecord->getSlackData($record);
+ $dataArray['token'] = $this->token;
- $dataArray['attachments'] = json_encode(array($attachment));
- } else {
- $dataArray['text'] = $record['message'];
- }
-
- if ($this->iconEmoji) {
- $dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
+ if (!empty($dataArray['attachments'])) {
+ $dataArray['attachments'] = json_encode($dataArray['attachments']);
}
return $dataArray;
@@ -239,6 +149,21 @@ private function buildHeader($content)
protected function write(array $record)
{
parent::write($record);
+ $this->finalizeWrite();
+ }
+
+ /**
+ * Finalizes the request by reading some bytes and then closing the socket
+ *
+ * If we do not read some but close the socket too early, slack sometimes
+ * drops the request entirely.
+ */
+ protected function finalizeWrite()
+ {
+ $res = $this->getResource();
+ if (is_resource($res)) {
+ @fread($res, 2048);
+ }
$this->closeSocket();
}
@@ -248,37 +173,48 @@ protected function write(array $record)
*
* @param int $level
* @return string
+ * @deprecated Use underlying SlackRecord instead
*/
protected function getAttachmentColor($level)
{
- switch (true) {
- case $level >= Logger::ERROR:
- return 'danger';
- case $level >= Logger::WARNING:
- return 'warning';
- case $level >= Logger::INFO:
- return 'good';
- default:
- return '#e3e4e6';
- }
+ trigger_error(
+ 'SlackHandler::getAttachmentColor() is deprecated. Use underlying SlackRecord instead.',
+ E_USER_DEPRECATED
+ );
+
+ return $this->slackRecord->getAttachmentColor($level);
}
/**
* Stringifies an array of key/value pairs to be used in attachment fields
*
- * @param array $fields
- * @access protected
+ * @param array $fields
* @return string
+ * @deprecated Use underlying SlackRecord instead
*/
protected function stringify($fields)
{
- $string = '';
- foreach ($fields as $var => $val) {
- $string .= $var.': '.$this->lineFormatter->stringify($val)." | ";
- }
+ trigger_error(
+ 'SlackHandler::stringify() is deprecated. Use underlying SlackRecord instead.',
+ E_USER_DEPRECATED
+ );
- $string = rtrim($string, " |");
+ return $this->slackRecord->stringify($fields);
+ }
+
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ parent::setFormatter($formatter);
+ $this->slackRecord->setFormatter($formatter);
+
+ return $this;
+ }
+
+ public function getFormatter()
+ {
+ $formatter = parent::getFormatter();
+ $this->slackRecord->setFormatter($formatter);
- return $string;
+ return $formatter;
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php
new file mode 100644
index 0000000..1ef85fa
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php
@@ -0,0 +1,120 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Logger;
+use Monolog\Handler\Slack\SlackRecord;
+
+/**
+ * Sends notifications through Slack Webhooks
+ *
+ * @author Haralan Dobrev
+ * @see https://api.slack.com/incoming-webhooks
+ */
+class SlackWebhookHandler extends AbstractProcessingHandler
+{
+ /**
+ * Slack Webhook token
+ * @var string
+ */
+ private $webhookUrl;
+
+ /**
+ * Instance of the SlackRecord util class preparing data for Slack API.
+ * @var SlackRecord
+ */
+ private $slackRecord;
+
+ /**
+ * @param string $webhookUrl Slack Webhook URL
+ * @param string|null $channel Slack channel (encoded ID or name)
+ * @param string|null $username Name of a bot
+ * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise)
+ * @param string|null $iconEmoji The emoji name to use (or null)
+ * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style
+ * @param bool $includeContextAndExtra Whether the attachment should include context and extra data
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param array $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']
+ */
+ public function __construct($webhookUrl, $channel = null, $username = null, $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeContextAndExtra = false, $level = Logger::CRITICAL, $bubble = true, array $excludeFields = array())
+ {
+ parent::__construct($level, $bubble);
+
+ $this->webhookUrl = $webhookUrl;
+
+ $this->slackRecord = new SlackRecord(
+ $channel,
+ $username,
+ $useAttachment,
+ $iconEmoji,
+ $useShortAttachment,
+ $includeContextAndExtra,
+ $excludeFields,
+ $this->formatter
+ );
+ }
+
+ public function getSlackRecord()
+ {
+ return $this->slackRecord;
+ }
+
+ public function getWebhookUrl()
+ {
+ return $this->webhookUrl;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ */
+ protected function write(array $record)
+ {
+ $postData = $this->slackRecord->getSlackData($record);
+ $postString = json_encode($postData);
+
+ $ch = curl_init();
+ $options = array(
+ CURLOPT_URL => $this->webhookUrl,
+ CURLOPT_POST => true,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_HTTPHEADER => array('Content-type: application/json'),
+ CURLOPT_POSTFIELDS => $postString
+ );
+ if (defined('CURLOPT_SAFE_UPLOAD')) {
+ $options[CURLOPT_SAFE_UPLOAD] = true;
+ }
+
+ curl_setopt_array($ch, $options);
+
+ Curl\Util::execute($ch);
+ }
+
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ parent::setFormatter($formatter);
+ $this->slackRecord->setFormatter($formatter);
+
+ return $this;
+ }
+
+ public function getFormatter()
+ {
+ $formatter = parent::getFormatter();
+ $this->slackRecord->setFormatter($formatter);
+
+ return $formatter;
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php
new file mode 100644
index 0000000..d3352ea
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php
@@ -0,0 +1,84 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Sends notifications through Slack's Slackbot
+ *
+ * @author Haralan Dobrev
+ * @see https://slack.com/apps/A0F81R8ET-slackbot
+ * @deprecated According to Slack the API used on this handler it is deprecated.
+ * Therefore this handler will be removed on 2.x
+ * Slack suggests to use webhooks instead. Please contact slack for more information.
+ */
+class SlackbotHandler extends AbstractProcessingHandler
+{
+ /**
+ * The slug of the Slack team
+ * @var string
+ */
+ private $slackTeam;
+
+ /**
+ * Slackbot token
+ * @var string
+ */
+ private $token;
+
+ /**
+ * Slack channel name
+ * @var string
+ */
+ private $channel;
+
+ /**
+ * @param string $slackTeam Slack team slug
+ * @param string $token Slackbot token
+ * @param string $channel Slack channel (encoded ID or name)
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($slackTeam, $token, $channel, $level = Logger::CRITICAL, $bubble = true)
+ {
+ @trigger_error('SlackbotHandler is deprecated and will be removed on 2.x', E_USER_DEPRECATED);
+ parent::__construct($level, $bubble);
+
+ $this->slackTeam = $slackTeam;
+ $this->token = $token;
+ $this->channel = $channel;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ */
+ protected function write(array $record)
+ {
+ $slackbotUrl = sprintf(
+ 'https://%s.slack.com/services/hooks/slackbot?token=%s&channel=%s',
+ $this->slackTeam,
+ $this->token,
+ $this->channel
+ );
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $slackbotUrl);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $record['message']);
+
+ Curl\Util::execute($ch);
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
index a3e7252..db50d97 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
@@ -25,14 +25,18 @@ class SocketHandler extends AbstractProcessingHandler
private $connectionTimeout;
private $resource;
private $timeout = 0;
+ private $writingTimeout = 10;
+ private $lastSentBytes = null;
+ private $chunkSize = null;
private $persistent = false;
private $errno;
private $errstr;
+ private $lastWritingAt;
/**
- * @param string $connectionString Socket connection string
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param string $connectionString Socket connection string
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true)
{
@@ -80,11 +84,11 @@ public function closeSocket()
/**
* Set socket connection to nbe persistent. It only has effect before the connection is initiated.
*
- * @param boolean $persistent
+ * @param bool $persistent
*/
public function setPersistent($persistent)
{
- $this->persistent = (boolean) $persistent;
+ $this->persistent = (bool) $persistent;
}
/**
@@ -113,6 +117,27 @@ public function setTimeout($seconds)
$this->timeout = (float) $seconds;
}
+ /**
+ * Set writing timeout. Only has effect during connection in the writing cycle.
+ *
+ * @param float $seconds 0 for no timeout
+ */
+ public function setWritingTimeout($seconds)
+ {
+ $this->validateTimeout($seconds);
+ $this->writingTimeout = (float) $seconds;
+ }
+
+ /**
+ * Set chunk size. Only has effect during connection in the writing cycle.
+ *
+ * @param float $bytes
+ */
+ public function setChunkSize($bytes)
+ {
+ $this->chunkSize = $bytes;
+ }
+
/**
* Get current connection string
*
@@ -126,7 +151,7 @@ public function getConnectionString()
/**
* Get persistent setting
*
- * @return boolean
+ * @return bool
*/
public function isPersistent()
{
@@ -153,12 +178,32 @@ public function getTimeout()
return $this->timeout;
}
+ /**
+ * Get current local writing timeout
+ *
+ * @return float
+ */
+ public function getWritingTimeout()
+ {
+ return $this->writingTimeout;
+ }
+
+ /**
+ * Get current chunk size
+ *
+ * @return float
+ */
+ public function getChunkSize()
+ {
+ return $this->chunkSize;
+ }
+
/**
* Check to see if the socket is currently available.
*
* UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details.
*
- * @return boolean
+ * @return bool
*/
public function isConnected()
{
@@ -195,6 +240,16 @@ protected function streamSetTimeout()
return stream_set_timeout($this->resource, $seconds, $microseconds);
}
+ /**
+ * Wrapper to allow mocking
+ *
+ * @see http://php.net/manual/en/function.stream-set-chunk-size.php
+ */
+ protected function streamSetChunkSize()
+ {
+ return stream_set_chunk_size($this->resource, $this->chunkSize);
+ }
+
/**
* Wrapper to allow mocking
*/
@@ -232,10 +287,19 @@ protected function generateDataStream($record)
return (string) $record['formatted'];
}
+ /**
+ * @return resource|null
+ */
+ protected function getResource()
+ {
+ return $this->resource;
+ }
+
private function connect()
{
$this->createSocketResource();
$this->setSocketTimeout();
+ $this->setStreamChunkSize();
}
private function createSocketResource()
@@ -258,10 +322,18 @@ private function setSocketTimeout()
}
}
+ private function setStreamChunkSize()
+ {
+ if ($this->chunkSize && !$this->streamSetChunkSize()) {
+ throw new \UnexpectedValueException("Failed setting chunk size with stream_set_chunk_size()");
+ }
+ }
+
private function writeToSocket($data)
{
$length = strlen($data);
$sent = 0;
+ $this->lastSentBytes = $sent;
while ($this->isConnected() && $sent < $length) {
if (0 == $sent) {
$chunk = $this->fwrite($data);
@@ -276,9 +348,38 @@ private function writeToSocket($data)
if ($socketInfo['timed_out']) {
throw new \RuntimeException("Write timed-out");
}
+
+ if ($this->writingIsTimedOut($sent)) {
+ throw new \RuntimeException("Write timed-out, no data sent for `{$this->writingTimeout}` seconds, probably we got disconnected (sent $sent of $length)");
+ }
}
if (!$this->isConnected() && $sent < $length) {
throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)");
}
}
+
+ private function writingIsTimedOut($sent)
+ {
+ $writingTimeout = (int) floor($this->writingTimeout);
+ if (0 === $writingTimeout) {
+ return false;
+ }
+
+ if ($sent !== $this->lastSentBytes) {
+ $this->lastWritingAt = time();
+ $this->lastSentBytes = $sent;
+
+ return false;
+ } else {
+ usleep(100);
+ }
+
+ if ((time() - $this->lastWritingAt) >= $writingTimeout) {
+ $this->closeSocket();
+
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
index 28b9b11..27d90e0 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
@@ -31,10 +31,10 @@ class StreamHandler extends AbstractProcessingHandler
/**
* @param resource|string $stream
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write)
- * @param Boolean $useLocking Try to lock log file before doing any writes
+ * @param bool $useLocking Try to lock log file before doing any writes
*
* @throws \Exception If a missing directory is not buildable
* @throws \InvalidArgumentException If stream is not a resource or string
@@ -59,10 +59,31 @@ public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $fi
*/
public function close()
{
- if (is_resource($this->stream)) {
+ if ($this->url && is_resource($this->stream)) {
fclose($this->stream);
}
$this->stream = null;
+ $this->dirCreated = null;
+ }
+
+ /**
+ * Return the currently active stream if it is open
+ *
+ * @return resource|null
+ */
+ public function getStream()
+ {
+ return $this->stream;
+ }
+
+ /**
+ * Return the stream URL if it was configured with a URL and not an active resource
+ *
+ * @return string|null
+ */
+ public function getUrl()
+ {
+ return $this->url;
}
/**
@@ -71,7 +92,7 @@ public function close()
protected function write(array $record)
{
if (!is_resource($this->stream)) {
- if (!$this->url) {
+ if (null === $this->url || '' === $this->url) {
throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
}
$this->createDir();
@@ -93,13 +114,23 @@ protected function write(array $record)
flock($this->stream, LOCK_EX);
}
- fwrite($this->stream, (string) $record['formatted']);
+ $this->streamWrite($this->stream, $record);
if ($this->useLocking) {
flock($this->stream, LOCK_UN);
}
}
+ /**
+ * Write to stream
+ * @param resource $stream
+ * @param array $record
+ */
+ protected function streamWrite($stream, array $record)
+ {
+ fwrite($stream, (string) $record['formatted']);
+ }
+
private function customErrorHandler($code, $msg)
{
$this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg);
@@ -137,7 +168,7 @@ private function createDir()
set_error_handler(array($this, 'customErrorHandler'));
$status = mkdir($dir, 0777, true);
restore_error_handler();
- if (false === $status) {
+ if (false === $status && !is_dir($dir)) {
throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and its not buildable: '.$this->errorMessage, $dir));
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
index 5c2b156..ac7b16f 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
@@ -12,6 +12,9 @@
namespace Monolog\Handler;
use Monolog\Logger;
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Formatter\LineFormatter;
+use Swift;
/**
* SwiftMailerHandler uses Swift_Mailer to send the emails
@@ -26,8 +29,8 @@ class SwiftMailerHandler extends MailHandler
/**
* @param \Swift_Mailer $mailer The mailer to use
* @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
{
@@ -45,11 +48,22 @@ protected function send($content, array $records)
$this->mailer->send($this->buildMessage($content, $records));
}
+ /**
+ * Gets the formatter for the Swift_Message subject.
+ *
+ * @param string $format The format of the subject
+ * @return FormatterInterface
+ */
+ protected function getSubjectFormatter($format)
+ {
+ return new LineFormatter($format);
+ }
+
/**
* Creates instance of Swift_Message to be sent
*
- * @param string $content formatted email body to be sent
- * @param array $records Log records that formed the content
+ * @param string $content formatted email body to be sent
+ * @param array $records Log records that formed the content
* @return \Swift_Message
*/
protected function buildMessage($content, array $records)
@@ -66,8 +80,17 @@ protected function buildMessage($content, array $records)
throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
}
+ if ($records) {
+ $subjectFormatter = $this->getSubjectFormatter($message->getSubject());
+ $message->setSubject($subjectFormatter->format($this->getHighestRecord($records)));
+ }
+
$message->setBody($content);
- $message->setDate(time());
+ if (version_compare(Swift::VERSION, '6.0.0', '>=')) {
+ $message->setDate(new \DateTimeImmutable());
+ } else {
+ $message->setDate(time());
+ }
return $message;
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
index 47c73e1..f770c80 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
@@ -32,11 +32,11 @@ class SyslogHandler extends AbstractSyslogHandler
protected $logopts;
/**
- * @param string $ident
- * @param mixed $facility
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
- * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID
+ * @param string $ident
+ * @param mixed $facility
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID
*/
public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
index 2e32fa7..4dfd5f5 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
@@ -18,22 +18,38 @@
* A Handler for logging to a remote syslogd server.
*
* @author Jesper Skovgaard Nielsen
+ * @author Dominik Kukacka
*/
class SyslogUdpHandler extends AbstractSyslogHandler
{
+ const RFC3164 = 0;
+ const RFC5424 = 1;
+
+ private $dateFormats = array(
+ self::RFC3164 => 'M d H:i:s',
+ self::RFC5424 => \DateTime::RFC3339,
+ );
+
protected $socket;
+ protected $ident;
+ protected $rfc;
/**
- * @param string $host
- * @param int $port
- * @param mixed $facility
- * @param integer $level The minimum logging level at which this handler will be triggered
- * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param string $host
+ * @param int $port
+ * @param mixed $facility
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param string $ident Program name or tag for each log message.
+ * @param int $rfc RFC to format the message for.
*/
- public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
+ public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php', $rfc = self::RFC5424)
{
parent::__construct($facility, $level, $bubble);
+ $this->ident = $ident;
+ $this->rfc = $rfc;
+
$this->socket = new UdpSocket($host, $port ?: 514);
}
@@ -59,17 +75,43 @@ private function splitMessageIntoLines($message)
$message = implode("\n", $message);
}
- return preg_split('/$\R?^/m', $message);
+ return preg_split('/$\R?^/m', $message, -1, PREG_SPLIT_NO_EMPTY);
}
/**
- * Make common syslog header (see rfc5424)
+ * Make common syslog header (see rfc5424 or rfc3164)
*/
protected function makeCommonSyslogHeader($severity)
{
$priority = $severity + $this->facility;
- return "<$priority>1 ";
+ if (!$pid = getmypid()) {
+ $pid = '-';
+ }
+
+ if (!$hostname = gethostname()) {
+ $hostname = '-';
+ }
+
+ $date = $this->getDateTime();
+
+ if ($this->rfc === self::RFC3164) {
+ return "<$priority>" .
+ $date . " " .
+ $hostname . " " .
+ $this->ident . "[" . $pid . "]: ";
+ } else {
+ return "<$priority>1 " .
+ $date . " " .
+ $hostname . " " .
+ $this->ident . " " .
+ $pid . " - - ";
+ }
+ }
+
+ protected function getDateTime()
+ {
+ return date($this->dateFormats[$this->rfc]);
}
/**
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
index e24fa9e..478db0a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
@@ -18,74 +18,103 @@
*
* @author Jordi Boggiano
*
- * @method boolean hasEmergency($record)
- * @method boolean hasAlert($record)
- * @method boolean hasCritical($record)
- * @method boolean hasError($record)
- * @method boolean hasWarning($record)
- * @method boolean hasNotice($record)
- * @method boolean hasInfo($record)
- * @method boolean hasDebug($record)
+ * @method bool hasEmergency($record)
+ * @method bool hasAlert($record)
+ * @method bool hasCritical($record)
+ * @method bool hasError($record)
+ * @method bool hasWarning($record)
+ * @method bool hasNotice($record)
+ * @method bool hasInfo($record)
+ * @method bool hasDebug($record)
*
- * @method boolean hasEmergencyRecords()
- * @method boolean hasAlertRecords()
- * @method boolean hasCriticalRecords()
- * @method boolean hasErrorRecords()
- * @method boolean hasWarningRecords()
- * @method boolean hasNoticeRecords()
- * @method boolean hasInfoRecords()
- * @method boolean hasDebugRecords()
+ * @method bool hasEmergencyRecords()
+ * @method bool hasAlertRecords()
+ * @method bool hasCriticalRecords()
+ * @method bool hasErrorRecords()
+ * @method bool hasWarningRecords()
+ * @method bool hasNoticeRecords()
+ * @method bool hasInfoRecords()
+ * @method bool hasDebugRecords()
*
- * @method boolean hasEmergencyThatContains($message)
- * @method boolean hasAlertThatContains($message)
- * @method boolean hasCriticalThatContains($message)
- * @method boolean hasErrorThatContains($message)
- * @method boolean hasWarningThatContains($message)
- * @method boolean hasNoticeThatContains($message)
- * @method boolean hasInfoThatContains($message)
- * @method boolean hasDebugThatContains($message)
+ * @method bool hasEmergencyThatContains($message)
+ * @method bool hasAlertThatContains($message)
+ * @method bool hasCriticalThatContains($message)
+ * @method bool hasErrorThatContains($message)
+ * @method bool hasWarningThatContains($message)
+ * @method bool hasNoticeThatContains($message)
+ * @method bool hasInfoThatContains($message)
+ * @method bool hasDebugThatContains($message)
*
- * @method boolean hasEmergencyThatMatches($message)
- * @method boolean hasAlertThatMatches($message)
- * @method boolean hasCriticalThatMatches($message)
- * @method boolean hasErrorThatMatches($message)
- * @method boolean hasWarningThatMatches($message)
- * @method boolean hasNoticeThatMatches($message)
- * @method boolean hasInfoThatMatches($message)
- * @method boolean hasDebugThatMatches($message)
+ * @method bool hasEmergencyThatMatches($message)
+ * @method bool hasAlertThatMatches($message)
+ * @method bool hasCriticalThatMatches($message)
+ * @method bool hasErrorThatMatches($message)
+ * @method bool hasWarningThatMatches($message)
+ * @method bool hasNoticeThatMatches($message)
+ * @method bool hasInfoThatMatches($message)
+ * @method bool hasDebugThatMatches($message)
*
- * @method boolean hasEmergencyThatPasses($message)
- * @method boolean hasAlertThatPasses($message)
- * @method boolean hasCriticalThatPasses($message)
- * @method boolean hasErrorThatPasses($message)
- * @method boolean hasWarningThatPasses($message)
- * @method boolean hasNoticeThatPasses($message)
- * @method boolean hasInfoThatPasses($message)
- * @method boolean hasDebugThatPasses($message)
+ * @method bool hasEmergencyThatPasses($message)
+ * @method bool hasAlertThatPasses($message)
+ * @method bool hasCriticalThatPasses($message)
+ * @method bool hasErrorThatPasses($message)
+ * @method bool hasWarningThatPasses($message)
+ * @method bool hasNoticeThatPasses($message)
+ * @method bool hasInfoThatPasses($message)
+ * @method bool hasDebugThatPasses($message)
*/
class TestHandler extends AbstractProcessingHandler
{
protected $records = array();
protected $recordsByLevel = array();
+ private $skipReset = false;
public function getRecords()
{
return $this->records;
}
- protected function hasRecordRecords($level)
+ public function clear()
+ {
+ $this->records = array();
+ $this->recordsByLevel = array();
+ }
+
+ public function reset()
+ {
+ if (!$this->skipReset) {
+ $this->clear();
+ }
+ }
+
+ public function setSkipReset($skipReset)
+ {
+ $this->skipReset = $skipReset;
+ }
+
+ public function hasRecords($level)
{
return isset($this->recordsByLevel[$level]);
}
- protected function hasRecord($record, $level)
+ /**
+ * @param string|array $record Either a message string or an array containing message and optionally context keys that will be checked against all records
+ * @param int $level Logger::LEVEL constant value
+ */
+ public function hasRecord($record, $level)
{
- if (is_array($record)) {
- $record = $record['message'];
+ if (is_string($record)) {
+ $record = array('message' => $record);
}
return $this->hasRecordThatPasses(function ($rec) use ($record) {
- return $rec['message'] === $record;
+ if ($rec['message'] !== $record['message']) {
+ return false;
+ }
+ if (isset($record['context']) && $rec['context'] !== $record['context']) {
+ return false;
+ }
+ return true;
}, $level);
}
@@ -134,7 +163,7 @@ protected function write(array $record)
public function __call($method, $args)
{
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
- $genericMethod = $matches[1] . 'Record' . $matches[3];
+ $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
$level = constant('Monolog\Logger::' . strtoupper($matches[2]));
if (method_exists($this, $genericMethod)) {
$args[] = $level;
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php
index 05a8817..7d7622a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php
@@ -35,6 +35,8 @@ public function handle(array $record)
$handler->handle($record);
} catch (\Exception $e) {
// What failure?
+ } catch (\Throwable $e) {
+ // What failure?
}
}
@@ -46,11 +48,24 @@ public function handle(array $record)
*/
public function handleBatch(array $records)
{
+ if ($this->processors) {
+ $processed = array();
+ foreach ($records as $record) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ $processed[] = $record;
+ }
+ $records = $processed;
+ }
+
foreach ($this->handlers as $handler) {
try {
$handler->handleBatch($records);
} catch (\Exception $e) {
// What failure?
+ } catch (\Throwable $e) {
+ // What failure?
}
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php b/application/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
index f22cf21..a20aeae 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
@@ -17,6 +17,7 @@
* Handler sending logs to Zend Monitor
*
* @author Christian Bergau
+ * @author Jason Davis
*/
class ZendMonitorHandler extends AbstractProcessingHandler
{
@@ -25,16 +26,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
*
* @var array
*/
- protected $levelMap = array(
- Logger::DEBUG => 1,
- Logger::INFO => 2,
- Logger::NOTICE => 3,
- Logger::WARNING => 4,
- Logger::ERROR => 5,
- Logger::CRITICAL => 6,
- Logger::ALERT => 7,
- Logger::EMERGENCY => 0,
- );
+ protected $levelMap = array();
/**
* Construct
@@ -46,8 +38,21 @@ class ZendMonitorHandler extends AbstractProcessingHandler
public function __construct($level = Logger::DEBUG, $bubble = true)
{
if (!function_exists('zend_monitor_custom_event')) {
- throw new MissingExtensionException('You must have Zend Server installed in order to use this handler');
+ throw new MissingExtensionException(
+ 'You must have Zend Server installed with Zend Monitor enabled in order to use this handler'
+ );
}
+ //zend monitor constants are not defined if zend monitor is not enabled.
+ $this->levelMap = array(
+ Logger::DEBUG => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
+ Logger::INFO => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
+ Logger::NOTICE => \ZEND_MONITOR_EVENT_SEVERITY_INFO,
+ Logger::WARNING => \ZEND_MONITOR_EVENT_SEVERITY_WARNING,
+ Logger::ERROR => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
+ Logger::CRITICAL => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
+ Logger::ALERT => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
+ Logger::EMERGENCY => \ZEND_MONITOR_EVENT_SEVERITY_ERROR,
+ );
parent::__construct($level, $bubble);
}
@@ -57,22 +62,23 @@ public function __construct($level = Logger::DEBUG, $bubble = true)
protected function write(array $record)
{
$this->writeZendMonitorCustomEvent(
- $this->levelMap[$record['level']],
+ Logger::getLevelName($record['level']),
$record['message'],
- $record['formatted']
+ $record['formatted'],
+ $this->levelMap[$record['level']]
);
}
/**
- * Write a record to Zend Monitor
- *
- * @param int $level
- * @param string $message
- * @param array $formatted
+ * Write to Zend Monitor Events
+ * @param string $type Text displayed in "Class Name (custom)" field
+ * @param string $message Text displayed in "Error String"
+ * @param mixed $formatted Displayed in Custom Variables tab
+ * @param int $severity Set the event severity level (-1,0,1)
*/
- protected function writeZendMonitorCustomEvent($level, $message, $formatted)
+ protected function writeZendMonitorCustomEvent($type, $message, $formatted, $severity)
{
- zend_monitor_custom_event($level, $message, $formatted);
+ zend_monitor_custom_event($type, $message, $formatted, $severity);
}
/**
diff --git a/application/vendor/monolog/monolog/src/Monolog/Logger.php b/application/vendor/monolog/monolog/src/Monolog/Logger.php
index d31a098..05dfc81 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Logger.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Logger.php
@@ -15,6 +15,7 @@
use Monolog\Handler\StreamHandler;
use Psr\Log\LoggerInterface;
use Psr\Log\InvalidArgumentException;
+use Exception;
/**
* Monolog log channel
@@ -24,7 +25,7 @@
*
* @author Jordi Boggiano
*/
-class Logger implements LoggerInterface
+class Logger implements LoggerInterface, ResettableInterface
{
/**
* Detailed debug information
@@ -92,14 +93,14 @@ class Logger implements LoggerInterface
* @var array $levels Logging levels
*/
protected static $levels = array(
- 100 => 'DEBUG',
- 200 => 'INFO',
- 250 => 'NOTICE',
- 300 => 'WARNING',
- 400 => 'ERROR',
- 500 => 'CRITICAL',
- 550 => 'ALERT',
- 600 => 'EMERGENCY',
+ self::DEBUG => 'DEBUG',
+ self::INFO => 'INFO',
+ self::NOTICE => 'NOTICE',
+ self::WARNING => 'WARNING',
+ self::ERROR => 'ERROR',
+ self::CRITICAL => 'CRITICAL',
+ self::ALERT => 'ALERT',
+ self::EMERGENCY => 'EMERGENCY',
);
/**
@@ -128,6 +129,16 @@ class Logger implements LoggerInterface
*/
protected $processors;
+ /**
+ * @var bool
+ */
+ protected $microsecondTimestamps = true;
+
+ /**
+ * @var callable
+ */
+ protected $exceptionHandler;
+
/**
* @param string $name The logging channel
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
@@ -136,7 +147,7 @@ class Logger implements LoggerInterface
public function __construct($name, array $handlers = array(), array $processors = array())
{
$this->name = $name;
- $this->handlers = $handlers;
+ $this->setHandlers($handlers);
$this->processors = $processors;
}
@@ -148,10 +159,23 @@ public function getName()
return $this->name;
}
+ /**
+ * Return a new cloned instance with the name changed
+ *
+ * @return static
+ */
+ public function withName($name)
+ {
+ $new = clone $this;
+ $new->name = $name;
+
+ return $new;
+ }
+
/**
* Pushes a handler on to the stack.
*
- * @param HandlerInterface $handler
+ * @param HandlerInterface $handler
* @return $this
*/
public function pushHandler(HandlerInterface $handler)
@@ -180,7 +204,7 @@ public function popHandler()
*
* If a map is passed, keys will be ignored.
*
- * @param HandlerInterface[] $handlers
+ * @param HandlerInterface[] $handlers
* @return $this
*/
public function setHandlers(array $handlers)
@@ -204,7 +228,7 @@ public function getHandlers()
/**
* Adds a processor on to the stack.
*
- * @param callable $callback
+ * @param callable $callback
* @return $this
*/
public function pushProcessor($callback)
@@ -239,13 +263,31 @@ public function getProcessors()
return $this->processors;
}
+ /**
+ * Control the use of microsecond resolution timestamps in the 'datetime'
+ * member of new records.
+ *
+ * Generating microsecond resolution timestamps by calling
+ * microtime(true), formatting the result via sprintf() and then parsing
+ * the resulting string via \DateTime::createFromFormat() can incur
+ * a measurable runtime overhead vs simple usage of DateTime to capture
+ * a second resolution timestamp in systems which generate a large number
+ * of log events.
+ *
+ * @param bool $micro True to use microtime() to create timestamps
+ */
+ public function useMicrosecondTimestamps($micro)
+ {
+ $this->microsecondTimestamps = (bool) $micro;
+ }
+
/**
* Adds a log record.
*
- * @param integer $level The logging level
+ * @param int $level The logging level
* @param string $message The log message
* @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @return bool Whether the record has been processed
*/
public function addRecord($level, $message, array $context = array())
{
@@ -257,11 +299,14 @@ public function addRecord($level, $message, array $context = array())
// check if any handler will handle this message so we can return early and save cycles
$handlerKey = null;
- foreach ($this->handlers as $key => $handler) {
+ reset($this->handlers);
+ while ($handler = current($this->handlers)) {
if ($handler->isHandling(array('level' => $level))) {
- $handlerKey = $key;
+ $handlerKey = key($this->handlers);
break;
}
+
+ next($this->handlers);
}
if (null === $handlerKey) {
@@ -272,33 +317,93 @@ public function addRecord($level, $message, array $context = array())
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
}
+ // php7.1+ always has microseconds enabled, so we do not need this hack
+ if ($this->microsecondTimestamps && PHP_VERSION_ID < 70100) {
+ $ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone);
+ } else {
+ $ts = new \DateTime(null, static::$timezone);
+ }
+ $ts->setTimezone(static::$timezone);
+
$record = array(
'message' => (string) $message,
'context' => $context,
'level' => $level,
'level_name' => $levelName,
'channel' => $this->name,
- 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
+ 'datetime' => $ts,
'extra' => array(),
);
- foreach ($this->processors as $processor) {
- $record = call_user_func($processor, $record);
- }
- while (isset($this->handlers[$handlerKey]) &&
- false === $this->handlers[$handlerKey]->handle($record)) {
- $handlerKey++;
+ try {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+
+ while ($handler = current($this->handlers)) {
+ if (true === $handler->handle($record)) {
+ break;
+ }
+
+ next($this->handlers);
+ }
+ } catch (Exception $e) {
+ $this->handleException($e, $record);
}
return true;
}
+ /**
+ * Ends a log cycle and frees all resources used by handlers.
+ *
+ * Closing a Handler means flushing all buffers and freeing any open resources/handles.
+ * Handlers that have been closed should be able to accept log records again and re-open
+ * themselves on demand, but this may not always be possible depending on implementation.
+ *
+ * This is useful at the end of a request and will be called automatically on every handler
+ * when they get destructed.
+ */
+ public function close()
+ {
+ foreach ($this->handlers as $handler) {
+ if (method_exists($handler, 'close')) {
+ $handler->close();
+ }
+ }
+ }
+
+ /**
+ * Ends a log cycle and resets all handlers and processors to their initial state.
+ *
+ * Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal
+ * state, and getting it back to a state in which it can receive log records again.
+ *
+ * This is useful in case you want to avoid logs leaking between two requests or jobs when you
+ * have a long running process like a worker or an application server serving multiple requests
+ * in one process.
+ */
+ public function reset()
+ {
+ foreach ($this->handlers as $handler) {
+ if ($handler instanceof ResettableInterface) {
+ $handler->reset();
+ }
+ }
+
+ foreach ($this->processors as $processor) {
+ if ($processor instanceof ResettableInterface) {
+ $processor->reset();
+ }
+ }
+ }
+
/**
* Adds a log record at the DEBUG level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addDebug($message, array $context = array())
{
@@ -308,9 +413,9 @@ public function addDebug($message, array $context = array())
/**
* Adds a log record at the INFO level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addInfo($message, array $context = array())
{
@@ -320,9 +425,9 @@ public function addInfo($message, array $context = array())
/**
* Adds a log record at the NOTICE level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addNotice($message, array $context = array())
{
@@ -332,9 +437,9 @@ public function addNotice($message, array $context = array())
/**
* Adds a log record at the WARNING level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addWarning($message, array $context = array())
{
@@ -344,9 +449,9 @@ public function addWarning($message, array $context = array())
/**
* Adds a log record at the ERROR level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addError($message, array $context = array())
{
@@ -356,9 +461,9 @@ public function addError($message, array $context = array())
/**
* Adds a log record at the CRITICAL level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addCritical($message, array $context = array())
{
@@ -368,9 +473,9 @@ public function addCritical($message, array $context = array())
/**
* Adds a log record at the ALERT level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addAlert($message, array $context = array())
{
@@ -380,9 +485,9 @@ public function addAlert($message, array $context = array())
/**
* Adds a log record at the EMERGENCY level.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function addEmergency($message, array $context = array())
{
@@ -402,7 +507,7 @@ public static function getLevels()
/**
* Gets the name of the logging level.
*
- * @param integer $level
+ * @param int $level
* @return string
*/
public static function getLevelName($level)
@@ -432,8 +537,8 @@ public static function toMonologLevel($level)
/**
* Checks whether the Logger has a handler that listens on the given level
*
- * @param integer $level
- * @return Boolean
+ * @param int $level
+ * @return bool
*/
public function isHandling($level)
{
@@ -450,15 +555,52 @@ public function isHandling($level)
return false;
}
+ /**
+ * Set a custom exception handler
+ *
+ * @param callable $callback
+ * @return $this
+ */
+ public function setExceptionHandler($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new \InvalidArgumentException('Exception handler must be valid callable (callback or object with an __invoke method), '.var_export($callback, true).' given');
+ }
+ $this->exceptionHandler = $callback;
+
+ return $this;
+ }
+
+ /**
+ * @return callable
+ */
+ public function getExceptionHandler()
+ {
+ return $this->exceptionHandler;
+ }
+
+ /**
+ * Delegates exception management to the custom exception handler,
+ * or throws the exception if no custom handler is set.
+ */
+ protected function handleException(Exception $e, array $record)
+ {
+ if (!$this->exceptionHandler) {
+ throw $e;
+ }
+
+ call_user_func($this->exceptionHandler, $e, $record);
+ }
+
/**
* Adds a log record at an arbitrary level.
*
* This method allows for compatibility with common interfaces.
*
* @param mixed $level The log level
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function log($level, $message, array $context = array())
{
@@ -472,9 +614,9 @@ public function log($level, $message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function debug($message, array $context = array())
{
@@ -486,9 +628,9 @@ public function debug($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function info($message, array $context = array())
{
@@ -500,9 +642,9 @@ public function info($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function notice($message, array $context = array())
{
@@ -514,9 +656,9 @@ public function notice($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function warn($message, array $context = array())
{
@@ -528,9 +670,9 @@ public function warn($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function warning($message, array $context = array())
{
@@ -542,9 +684,9 @@ public function warning($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function err($message, array $context = array())
{
@@ -556,9 +698,9 @@ public function err($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function error($message, array $context = array())
{
@@ -570,9 +712,9 @@ public function error($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function crit($message, array $context = array())
{
@@ -584,9 +726,9 @@ public function crit($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function critical($message, array $context = array())
{
@@ -598,9 +740,9 @@ public function critical($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function alert($message, array $context = array())
{
@@ -612,9 +754,9 @@ public function alert($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function emerg($message, array $context = array())
{
@@ -626,9 +768,9 @@ public function emerg($message, array $context = array())
*
* This method allows for compatibility with common interfaces.
*
- * @param string $message The log message
- * @param array $context The log context
- * @return Boolean Whether the record has been processed
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return bool Whether the record has been processed
*/
public function emergency($message, array $context = array())
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
index 1899400..9fc3f50 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
@@ -19,7 +19,7 @@
* @author Nick Otter
* @author Jordi Boggiano
*/
-class GitProcessor
+class GitProcessor implements ProcessorInterface
{
private $level;
private static $cache;
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
index 8f553fe..6ae192a 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
@@ -24,21 +24,24 @@
*
* @author Jordi Boggiano
*/
-class IntrospectionProcessor
+class IntrospectionProcessor implements ProcessorInterface
{
private $level;
private $skipClassesPartials;
+ private $skipStackFramesCount;
+
private $skipFunctions = array(
'call_user_func',
'call_user_func_array',
);
- public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array())
+ public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0)
{
$this->level = Logger::toMonologLevel($level);
$this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials);
+ $this->skipStackFramesCount = $skipStackFramesCount;
}
/**
@@ -52,7 +55,12 @@ public function __invoke(array $record)
return $record;
}
- $trace = debug_backtrace();
+ /*
+ * http://php.net/manual/en/function.debug-backtrace.php
+ * As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added.
+ * Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'.
+ */
+ $trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
// skip first since it's always the current method
array_shift($trace);
@@ -77,6 +85,8 @@ public function __invoke(array $record)
break;
}
+ $i += $this->skipStackFramesCount;
+
// we should have the call source now
$record['extra'] = array_merge(
$record['extra'],
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
index eb802c0..2a379a3 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
@@ -16,26 +16,26 @@
*
* @author Rob Jensen
*/
-abstract class MemoryProcessor
+abstract class MemoryProcessor implements ProcessorInterface
{
/**
- * @var boolean If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported.
+ * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported.
*/
protected $realUsage;
/**
- * @var boolean If true, then format memory size to human readable string (MB, KB, B depending on size)
+ * @var bool If true, then format memory size to human readable string (MB, KB, B depending on size)
*/
protected $useFormatting;
/**
- * @param boolean $realUsage Set this to true to get the real size of memory allocated from system.
- * @param boolean $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size)
+ * @param bool $realUsage Set this to true to get the real size of memory allocated from system.
+ * @param bool $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size)
*/
public function __construct($realUsage = true, $useFormatting = true)
{
- $this->realUsage = (boolean) $realUsage;
- $this->useFormatting = (boolean) $useFormatting;
+ $this->realUsage = (bool) $realUsage;
+ $this->useFormatting = (bool) $useFormatting;
}
/**
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php
new file mode 100644
index 0000000..2f5b326
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php
@@ -0,0 +1,63 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\Logger;
+
+/**
+ * Injects Hg branch and Hg revision number in all records
+ *
+ * @author Jonathan A. Schweder
+ */
+class MercurialProcessor implements ProcessorInterface
+{
+ private $level;
+ private static $cache;
+
+ public function __construct($level = Logger::DEBUG)
+ {
+ $this->level = Logger::toMonologLevel($level);
+ }
+
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ // return if the level is not high enough
+ if ($record['level'] < $this->level) {
+ return $record;
+ }
+
+ $record['extra']['hg'] = self::getMercurialInfo();
+
+ return $record;
+ }
+
+ private static function getMercurialInfo()
+ {
+ if (self::$cache) {
+ return self::$cache;
+ }
+
+ $result = explode(' ', trim(`hg id -nb`));
+ if (count($result) >= 3) {
+ return self::$cache = array(
+ 'branch' => $result[1],
+ 'revision' => $result[2],
+ );
+ }
+
+ return self::$cache = array();
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
index 9d3f559..66b80fb 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
@@ -16,7 +16,7 @@
*
* @author Andreas Hörnicke
*/
-class ProcessIdProcessor
+class ProcessIdProcessor implements ProcessorInterface
{
/**
* @param array $record
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php b/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php
new file mode 100644
index 0000000..7e64d4d
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * An optional interface to allow labelling Monolog processors.
+ *
+ * @author Nicolas Grekas
+ */
+interface ProcessorInterface
+{
+ /**
+ * @return array The processed records
+ */
+ public function __invoke(array $records);
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
index c2686ce..0088505 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
@@ -11,6 +11,8 @@
namespace Monolog\Processor;
+use Monolog\Utils;
+
/**
* Processes a record's message according to PSR-3 rules
*
@@ -18,7 +20,7 @@
*
* @author Jordi Boggiano
*/
-class PsrLogMessageProcessor
+class PsrLogMessageProcessor implements ProcessorInterface
{
/**
* @param array $record
@@ -35,7 +37,7 @@ public function __invoke(array $record)
if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) {
$replacements['{'.$key.'}'] = $val;
} elseif (is_object($val)) {
- $replacements['{'.$key.'}'] = '[object '.get_class($val).']';
+ $replacements['{'.$key.'}'] = '[object '.Utils::getClass($val).']';
} else {
$replacements['{'.$key.'}'] = '['.gettype($val).']';
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
index 7e2df2a..615a4d9 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
@@ -16,7 +16,7 @@
*
* @author Martijn Riemers
*/
-class TagProcessor
+class TagProcessor implements ProcessorInterface
{
private $tags;
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
index 812707c..d1f708c 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
@@ -11,12 +11,14 @@
namespace Monolog\Processor;
+use Monolog\ResettableInterface;
+
/**
* Adds a unique identifier into records
*
* @author Simon Mönch
*/
-class UidProcessor
+class UidProcessor implements ProcessorInterface, ResettableInterface
{
private $uid;
@@ -26,7 +28,8 @@ public function __construct($length = 7)
throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
}
- $this->uid = substr(hash('md5', uniqid('', true)), 0, $length);
+
+ $this->uid = $this->generateUid($length);
}
public function __invoke(array $record)
@@ -43,4 +46,14 @@ public function getUid()
{
return $this->uid;
}
+
+ public function reset()
+ {
+ $this->uid = $this->generateUid(strlen($this->uid));
+ }
+
+ private function generateUid($length)
+ {
+ return substr(hash('md5', uniqid('', true)), 0, $length);
+ }
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/application/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
index 21f22a6..684188f 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
@@ -16,7 +16,7 @@
*
* @author Jordi Boggiano
*/
-class WebProcessor
+class WebProcessor implements ProcessorInterface
{
/**
* @var array|\ArrayAccess
@@ -24,6 +24,10 @@ class WebProcessor
protected $serverData;
/**
+ * Default fields
+ *
+ * Array is structured as [key in record.extra => key in $serverData]
+ *
* @var array
*/
protected $extraFields = array(
@@ -36,7 +40,7 @@ class WebProcessor
/**
* @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
- * @param array|null $extraFields Extra field names to be added (all available by default)
+ * @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
*/
public function __construct($serverData = null, array $extraFields = null)
{
@@ -49,10 +53,14 @@ public function __construct($serverData = null, array $extraFields = null)
}
if (null !== $extraFields) {
- foreach (array_keys($this->extraFields) as $fieldName) {
- if (!in_array($fieldName, $extraFields)) {
- unset($this->extraFields[$fieldName]);
+ if (isset($extraFields[0])) {
+ foreach (array_keys($this->extraFields) as $fieldName) {
+ if (!in_array($fieldName, $extraFields)) {
+ unset($this->extraFields[$fieldName]);
+ }
}
+ } else {
+ $this->extraFields = $extraFields;
}
}
}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Registry.php b/application/vendor/monolog/monolog/src/Monolog/Registry.php
index a33cb7c..159b751 100644
--- a/application/vendor/monolog/monolog/src/Monolog/Registry.php
+++ b/application/vendor/monolog/monolog/src/Monolog/Registry.php
@@ -49,7 +49,7 @@ class Registry
*
* @param Logger $logger Instance of the logging channel
* @param string|null $name Name of the logging channel ($logger->getName() by default)
- * @param boolean $overwrite Overwrite instance in the registry if the given name already exists?
+ * @param bool $overwrite Overwrite instance in the registry if the given name already exists?
* @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
*/
public static function addLogger(Logger $logger, $name = null, $overwrite = false)
@@ -107,8 +107,8 @@ public static function clear()
* Gets Logger instance from the registry
*
* @param string $name Name of the requested Logger instance
- * @return Logger Requested instance of Logger
* @throws \InvalidArgumentException If named Logger instance is not in the registry
+ * @return Logger Requested instance of Logger
*/
public static function getInstance($name)
{
@@ -124,8 +124,8 @@ public static function getInstance($name)
*
* @param string $name Name of the requested Logger instance
* @param array $arguments Arguments passed to static method call
- * @return Logger Requested instance of Logger
* @throws \InvalidArgumentException If named Logger instance is not in the registry
+ * @return Logger Requested instance of Logger
*/
public static function __callStatic($name, $arguments)
{
diff --git a/application/vendor/monolog/monolog/src/Monolog/ResettableInterface.php b/application/vendor/monolog/monolog/src/Monolog/ResettableInterface.php
new file mode 100644
index 0000000..635bc77
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/ResettableInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+/**
+ * Handler or Processor implementing this interface will be reset when Logger::reset() is called.
+ *
+ * Resetting ends a log cycle gets them back to their initial state.
+ *
+ * Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal
+ * state, and getting it back to a state in which it can receive log records again.
+ *
+ * This is useful in case you want to avoid logs leaking between two requests or jobs when you
+ * have a long running process like a worker or an application server serving multiple requests
+ * in one process.
+ *
+ * @author Grégoire Pineau
+ */
+interface ResettableInterface
+{
+ public function reset();
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/SignalHandler.php b/application/vendor/monolog/monolog/src/Monolog/SignalHandler.php
new file mode 100644
index 0000000..d87018f
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/SignalHandler.php
@@ -0,0 +1,115 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
+use ReflectionExtension;
+
+/**
+ * Monolog POSIX signal handler
+ *
+ * @author Robert Gust-Bardon
+ */
+class SignalHandler
+{
+ private $logger;
+
+ private $previousSignalHandler = array();
+ private $signalLevelMap = array();
+ private $signalRestartSyscalls = array();
+
+ public function __construct(LoggerInterface $logger)
+ {
+ $this->logger = $logger;
+ }
+
+ public function registerSignalHandler($signo, $level = LogLevel::CRITICAL, $callPrevious = true, $restartSyscalls = true, $async = true)
+ {
+ if (!extension_loaded('pcntl') || !function_exists('pcntl_signal')) {
+ return $this;
+ }
+
+ if ($callPrevious) {
+ if (function_exists('pcntl_signal_get_handler')) {
+ $handler = pcntl_signal_get_handler($signo);
+ if ($handler === false) {
+ return $this;
+ }
+ $this->previousSignalHandler[$signo] = $handler;
+ } else {
+ $this->previousSignalHandler[$signo] = true;
+ }
+ } else {
+ unset($this->previousSignalHandler[$signo]);
+ }
+ $this->signalLevelMap[$signo] = $level;
+ $this->signalRestartSyscalls[$signo] = $restartSyscalls;
+
+ if (function_exists('pcntl_async_signals') && $async !== null) {
+ pcntl_async_signals($async);
+ }
+
+ pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls);
+
+ return $this;
+ }
+
+ public function handleSignal($signo, array $siginfo = null)
+ {
+ static $signals = array();
+
+ if (!$signals && extension_loaded('pcntl')) {
+ $pcntl = new ReflectionExtension('pcntl');
+ $constants = $pcntl->getConstants();
+ if (!$constants) {
+ // HHVM 3.24.2 returns an empty array.
+ $constants = get_defined_constants(true);
+ $constants = $constants['Core'];
+ }
+ foreach ($constants as $name => $value) {
+ if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) {
+ $signals[$value] = $name;
+ }
+ }
+ unset($constants);
+ }
+
+ $level = isset($this->signalLevelMap[$signo]) ? $this->signalLevelMap[$signo] : LogLevel::CRITICAL;
+ $signal = isset($signals[$signo]) ? $signals[$signo] : $signo;
+ $context = isset($siginfo) ? $siginfo : array();
+ $this->logger->log($level, sprintf('Program received signal %s', $signal), $context);
+
+ if (!isset($this->previousSignalHandler[$signo])) {
+ return;
+ }
+
+ if ($this->previousSignalHandler[$signo] === true || $this->previousSignalHandler[$signo] === SIG_DFL) {
+ if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch')
+ && extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill')) {
+ $restartSyscalls = isset($this->signalRestartSyscalls[$signo]) ? $this->signalRestartSyscalls[$signo] : true;
+ pcntl_signal($signo, SIG_DFL, $restartSyscalls);
+ pcntl_sigprocmask(SIG_UNBLOCK, array($signo), $oldset);
+ posix_kill(posix_getpid(), $signo);
+ pcntl_signal_dispatch();
+ pcntl_sigprocmask(SIG_SETMASK, $oldset);
+ pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls);
+ }
+ } elseif (is_callable($this->previousSignalHandler[$signo])) {
+ if (PHP_VERSION_ID >= 70100) {
+ $this->previousSignalHandler[$signo]($signo, $siginfo);
+ } else {
+ $this->previousSignalHandler[$signo]($signo);
+ }
+ }
+ }
+}
diff --git a/application/vendor/monolog/monolog/src/Monolog/Utils.php b/application/vendor/monolog/monolog/src/Monolog/Utils.php
new file mode 100644
index 0000000..eb9be86
--- /dev/null
+++ b/application/vendor/monolog/monolog/src/Monolog/Utils.php
@@ -0,0 +1,25 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+class Utils
+{
+ /**
+ * @internal
+ */
+ public static function getClass($object)
+ {
+ $class = \get_class($object);
+
+ return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
+ }
+}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php
deleted file mode 100644
index a9a3f30..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog;
-
-use Monolog\Handler\TestHandler;
-
-class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
-{
- public function testHandleError()
- {
- $logger = new Logger('test', array($handler = new TestHandler));
- $errHandler = new ErrorHandler($logger);
-
- $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
- trigger_error('Foo', E_USER_ERROR);
- $this->assertCount(1, $handler->getRecords());
- $this->assertTrue($handler->hasErrorRecords());
- trigger_error('Foo', E_USER_NOTICE);
- $this->assertCount(2, $handler->getRecords());
- $this->assertTrue($handler->hasEmergencyRecords());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
deleted file mode 100644
index e7f7334..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
+++ /dev/null
@@ -1,158 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-
-class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @covers Monolog\Formatter\ChromePHPFormatter::format
- */
- public function testDefaultFormat()
- {
- $formatter = new ChromePHPFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('ip' => '127.0.0.1'),
- 'message' => 'log',
- );
-
- $message = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'meh',
- array(
- 'message' => 'log',
- 'context' => array('from' => 'logger'),
- 'extra' => array('ip' => '127.0.0.1'),
- ),
- 'unknown',
- 'error'
- ),
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\ChromePHPFormatter::format
- */
- public function testFormatWithFileAndLine()
- {
- $formatter = new ChromePHPFormatter();
- $record = array(
- 'level' => Logger::CRITICAL,
- 'level_name' => 'CRITICAL',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
- 'message' => 'log',
- );
-
- $message = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'meh',
- array(
- 'message' => 'log',
- 'context' => array('from' => 'logger'),
- 'extra' => array('ip' => '127.0.0.1'),
- ),
- 'test : 14',
- 'error'
- ),
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\ChromePHPFormatter::format
- */
- public function testFormatWithoutContext()
- {
- $formatter = new ChromePHPFormatter();
- $record = array(
- 'level' => Logger::DEBUG,
- 'level_name' => 'DEBUG',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $message = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'meh',
- 'log',
- 'unknown',
- 'log'
- ),
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch
- */
- public function testBatchFormatThrowException()
- {
- $formatter = new ChromePHPFormatter();
- $records = array(
- array(
- 'level' => Logger::INFO,
- 'level_name' => 'INFO',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- ),
- array(
- 'level' => Logger::WARNING,
- 'level_name' => 'WARNING',
- 'channel' => 'foo',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log2',
- ),
- );
-
- $this->assertEquals(
- array(
- array(
- 'meh',
- 'log',
- 'unknown',
- 'info'
- ),
- array(
- 'foo',
- 'log2',
- 'unknown',
- 'warn'
- ),
- ),
- $formatter->formatBatch($records)
- );
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php
deleted file mode 100644
index 546e5c2..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-
-class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- if (!class_exists("Elastica\Document")) {
- $this->markTestSkipped("ruflin/elastica not installed");
- }
- }
-
- /**
- * @covers Monolog\Formatter\ElasticaFormatter::__construct
- * @covers Monolog\Formatter\ElasticaFormatter::format
- * @covers Monolog\Formatter\ElasticaFormatter::getDocument
- */
- public function testFormat()
- {
- // test log message
- $msg = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- // expected values
- $expected = $msg;
- $expected['datetime'] = '1970-01-01T00:00:00+0000';
- $expected['context'] = array(
- 'class' => '[object] (stdClass: {})',
- 'foo' => 7,
- 0 => 'bar',
- );
-
- // format log message
- $formatter = new ElasticaFormatter('my_index', 'doc_type');
- $doc = $formatter->format($msg);
- $this->assertInstanceOf('Elastica\Document', $doc);
-
- // Document parameters
- $params = $doc->getParams();
- $this->assertEquals('my_index', $params['_index']);
- $this->assertEquals('doc_type', $params['_type']);
-
- // Document data values
- $data = $doc->getData();
- foreach (array_keys($expected) as $key) {
- $this->assertEquals($expected[$key], $data[$key]);
- }
- }
-
- /**
- * @covers Monolog\Formatter\ElasticaFormatter::getIndex
- * @covers Monolog\Formatter\ElasticaFormatter::getType
- */
- public function testGetters()
- {
- $formatter = new ElasticaFormatter('my_index', 'doc_type');
- $this->assertEquals('my_index', $formatter->getIndex());
- $this->assertEquals('doc_type', $formatter->getType());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php
deleted file mode 100644
index 1b2fd97..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-use Monolog\TestCase;
-
-class FlowdockFormatterTest extends TestCase
-{
- /**
- * @covers Monolog\Formatter\FlowdockFormatter::format
- */
- public function testFormat()
- {
- $formatter = new FlowdockFormatter('test_source', 'source@test.com');
- $record = $this->getRecord();
-
- $expected = array(
- 'source' => 'test_source',
- 'from_address' => 'source@test.com',
- 'subject' => 'in test_source: WARNING - test',
- 'content' => 'test',
- 'tags' => array('#logs', '#warning', '#test'),
- 'project' => 'test_source',
- );
- $formatted = $formatter->format($record);
-
- $this->assertEquals($expected, $formatted['flowdock']);
- }
-
- /**
- * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch
- */
- public function testFormatBatch()
- {
- $formatter = new FlowdockFormatter('test_source', 'source@test.com');
- $records = array(
- $this->getRecord(Logger::WARNING),
- $this->getRecord(Logger::DEBUG),
- );
- $formatted = $formatter->formatBatch($records);
-
- $this->assertArrayHasKey('flowdock', $formatted[0]);
- $this->assertArrayHasKey('flowdock', $formatted[1]);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
deleted file mode 100644
index 6ac1485..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
+++ /dev/null
@@ -1,204 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-
-class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- if (!class_exists('\Gelf\Message')) {
- $this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed");
- }
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- */
- public function testDefaultFormatter()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
- $this->assertEquals(0, $message->getTimestamp());
- $this->assertEquals('log', $message->getShortMessage());
- $this->assertEquals('meh', $message->getFacility());
- $this->assertEquals(null, $message->getLine());
- $this->assertEquals(null, $message->getFile());
- $this->assertEquals($this->isLegacy() ? 3 : 'error', $message->getLevel());
- $this->assertNotEmpty($message->getHost());
-
- $formatter = new GelfMessageFormatter('mysystem');
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
- $this->assertEquals('mysystem', $message->getHost());
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- */
- public function testFormatWithFileAndLine()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('file' => 'test', 'line' => 14),
- 'message' => 'log',
- );
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
- $this->assertEquals('test', $message->getFile());
- $this->assertEquals(14, $message->getLine());
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- * @expectedException InvalidArgumentException
- */
- public function testFormatInvalidFails()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- );
-
- $formatter->format($record);
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- */
- public function testFormatWithContext()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
-
- $message_array = $message->toArray();
-
- $this->assertArrayHasKey('_ctxt_from', $message_array);
- $this->assertEquals('logger', $message_array['_ctxt_from']);
-
- // Test with extraPrefix
- $formatter = new GelfMessageFormatter(null, null, 'CTX');
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
-
- $message_array = $message->toArray();
-
- $this->assertArrayHasKey('_CTXfrom', $message_array);
- $this->assertEquals('logger', $message_array['_CTXfrom']);
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- */
- public function testFormatWithContextContainingException()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger', 'exception' => array(
- 'class' => '\Exception',
- 'file' => '/some/file/in/dir.php:56',
- 'trace' => array('/some/file/1.php:23', '/some/file/2.php:3')
- )),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log'
- );
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
-
- $this->assertEquals("/some/file/in/dir.php", $message->getFile());
- $this->assertEquals("56", $message->getLine());
- }
-
- /**
- * @covers Monolog\Formatter\GelfMessageFormatter::format
- */
- public function testFormatWithExtra()
- {
- $formatter = new GelfMessageFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
-
- $message_array = $message->toArray();
-
- $this->assertArrayHasKey('_key', $message_array);
- $this->assertEquals('pair', $message_array['_key']);
-
- // Test with extraPrefix
- $formatter = new GelfMessageFormatter(null, 'EXT');
- $message = $formatter->format($record);
-
- $this->assertInstanceOf('Gelf\Message', $message);
-
- $message_array = $message->toArray();
-
- $this->assertArrayHasKey('_EXTkey', $message_array);
- $this->assertEquals('pair', $message_array['_EXTkey']);
- }
-
- private function isLegacy()
- {
- return interface_exists('\Gelf\IMessagePublisher');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
deleted file mode 100644
index 69e2007..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-use Monolog\TestCase;
-
-class JsonFormatterTest extends TestCase
-{
- /**
- * @covers Monolog\Formatter\JsonFormatter::__construct
- * @covers Monolog\Formatter\JsonFormatter::getBatchMode
- * @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines
- */
- public function testConstruct()
- {
- $formatter = new JsonFormatter();
- $this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
- $this->assertEquals(true, $formatter->isAppendingNewlines());
- $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false);
- $this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
- $this->assertEquals(false, $formatter->isAppendingNewlines());
- }
-
- /**
- * @covers Monolog\Formatter\JsonFormatter::format
- */
- public function testFormat()
- {
- $formatter = new JsonFormatter();
- $record = $this->getRecord();
- $this->assertEquals(json_encode($record)."\n", $formatter->format($record));
-
- $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
- $record = $this->getRecord();
- $this->assertEquals(json_encode($record), $formatter->format($record));
- }
-
- /**
- * @covers Monolog\Formatter\JsonFormatter::formatBatch
- * @covers Monolog\Formatter\JsonFormatter::formatBatchJson
- */
- public function testFormatBatch()
- {
- $formatter = new JsonFormatter();
- $records = array(
- $this->getRecord(Logger::WARNING),
- $this->getRecord(Logger::DEBUG),
- );
- $this->assertEquals(json_encode($records), $formatter->formatBatch($records));
- }
-
- /**
- * @covers Monolog\Formatter\JsonFormatter::formatBatch
- * @covers Monolog\Formatter\JsonFormatter::formatBatchNewlines
- */
- public function testFormatBatchNewlines()
- {
- $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES);
- $records = $expected = array(
- $this->getRecord(Logger::WARNING),
- $this->getRecord(Logger::DEBUG),
- );
- array_walk($expected, function (&$value, $key) {
- $value = json_encode($value);
- });
- $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
deleted file mode 100644
index 875bd57..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
+++ /dev/null
@@ -1,208 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-/**
- * @covers Monolog\Formatter\LineFormatter
- */
-class LineFormatterTest extends \PHPUnit_Framework_TestCase
-{
- public function testDefFormatWithString()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'WARNING',
- 'channel' => 'log',
- 'context' => array(),
- 'message' => 'foo',
- 'datetime' => new \DateTime,
- 'extra' => array(),
- ));
- $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
- }
-
- public function testDefFormatWithArrayContext()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'message' => 'foo',
- 'datetime' => new \DateTime,
- 'extra' => array(),
- 'context' => array(
- 'foo' => 'bar',
- 'baz' => 'qux',
- 'bool' => false,
- 'null' => null,
- )
- ));
- $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux","bool":false,"null":null} []'."\n", $message);
- }
-
- public function testDefFormatExtras()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array('ip' => '127.0.0.1'),
- 'message' => 'log',
- ));
- $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message);
- }
-
- public function testFormatExtras()
- {
- $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array('ip' => '127.0.0.1', 'file' => 'test'),
- 'message' => 'log',
- ));
- $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message);
- }
-
- public function testContextAndExtraOptionallyNotShownIfEmpty()
- {
- $formatter = new LineFormatter(null, 'Y-m-d', false, true);
- $message = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- 'message' => 'log',
- ));
- $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log '."\n", $message);
- }
-
- public function testDefFormatWithObject()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
- 'message' => 'foobar',
- ));
-
- $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: bar)","baz":[],"res":"[resource] (stream)"}'."\n", $message);
- }
-
- public function testDefFormatWithException()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(array(
- 'level_name' => 'CRITICAL',
- 'channel' => 'core',
- 'context' => array('exception' => new \RuntimeException('Foo')),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- 'message' => 'foobar',
- ));
-
- $path = str_replace('\\/', '/', json_encode(__FILE__));
-
- $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
- }
-
- public function testDefFormatWithPreviousException()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $previous = new \LogicException('Wut?');
- $message = $formatter->format(array(
- 'level_name' => 'CRITICAL',
- 'channel' => 'core',
- 'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- 'message' => 'foobar',
- ));
-
- $path = str_replace('\\/', '/', json_encode(__FILE__));
-
- $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).', LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message);
- }
-
- public function testBatchFormat()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->formatBatch(array(
- array(
- 'level_name' => 'CRITICAL',
- 'channel' => 'test',
- 'message' => 'bar',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- ),
- array(
- 'level_name' => 'WARNING',
- 'channel' => 'log',
- 'message' => 'foo',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- ),
- ));
- $this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
- }
-
- public function testFormatShouldStripInlineLineBreaks()
- {
- $formatter = new LineFormatter(null, 'Y-m-d');
- $message = $formatter->format(
- array(
- 'message' => "foo\nbar",
- 'context' => array(),
- 'extra' => array(),
- )
- );
-
- $this->assertRegExp('/foo bar/', $message);
- }
-
- public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
- {
- $formatter = new LineFormatter(null, 'Y-m-d', true);
- $message = $formatter->format(
- array(
- 'message' => "foo\nbar",
- 'context' => array(),
- 'extra' => array(),
- )
- );
-
- $this->assertRegExp('/foo\nbar/', $message);
- }
-}
-
-class TestFoo
-{
- public $foo = 'foo';
-}
-
-class TestBar
-{
- public function __toString()
- {
- return 'bar';
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php
deleted file mode 100644
index 6d59b3f..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\TestCase;
-
-class LogglyFormatterTest extends TestCase
-{
- /**
- * @covers Monolog\Formatter\LogglyFormatter::__construct
- */
- public function testConstruct()
- {
- $formatter = new LogglyFormatter();
- $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
- $formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON);
- $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
- }
-
- /**
- * @covers Monolog\Formatter\LogglyFormatter::format
- */
- public function testFormat()
- {
- $formatter = new LogglyFormatter();
- $record = $this->getRecord();
- $formatted_decoded = json_decode($formatter->format($record), true);
- $this->assertArrayHasKey("timestamp", $formatted_decoded);
- $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
deleted file mode 100644
index de4a3c2..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
+++ /dev/null
@@ -1,289 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-
-class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testDefaultFormatter()
- {
- $formatter = new LogstashFormatter('test', 'hostname');
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
- $this->assertEquals('log', $message['@message']);
- $this->assertEquals('meh', $message['@fields']['channel']);
- $this->assertContains('meh', $message['@tags']);
- $this->assertEquals(Logger::ERROR, $message['@fields']['level']);
- $this->assertEquals('test', $message['@type']);
- $this->assertEquals('hostname', $message['@source']);
-
- $formatter = new LogstashFormatter('mysystem');
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals('mysystem', $message['@type']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithFileAndLine()
- {
- $formatter = new LogstashFormatter('test');
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('file' => 'test', 'line' => 14),
- 'message' => 'log',
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals('test', $message['@fields']['file']);
- $this->assertEquals(14, $message['@fields']['line']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithContext()
- {
- $formatter = new LogstashFormatter('test');
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $message_array = $message['@fields'];
-
- $this->assertArrayHasKey('ctxt_from', $message_array);
- $this->assertEquals('logger', $message_array['ctxt_from']);
-
- // Test with extraPrefix
- $formatter = new LogstashFormatter('test', null, null, 'CTX');
- $message = json_decode($formatter->format($record), true);
-
- $message_array = $message['@fields'];
-
- $this->assertArrayHasKey('CTXfrom', $message_array);
- $this->assertEquals('logger', $message_array['CTXfrom']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithExtra()
- {
- $formatter = new LogstashFormatter('test');
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $message_array = $message['@fields'];
-
- $this->assertArrayHasKey('key', $message_array);
- $this->assertEquals('pair', $message_array['key']);
-
- // Test with extraPrefix
- $formatter = new LogstashFormatter('test', null, 'EXT');
- $message = json_decode($formatter->format($record), true);
-
- $message_array = $message['@fields'];
-
- $this->assertArrayHasKey('EXTkey', $message_array);
- $this->assertEquals('pair', $message_array['EXTkey']);
- }
-
- public function testFormatWithApplicationName()
- {
- $formatter = new LogstashFormatter('app', 'test');
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('@type', $message);
- $this->assertEquals('app', $message['@type']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testDefaultFormatterV1()
- {
- $formatter = new LogstashFormatter('test', 'hostname', null, 'ctxt_', LogstashFormatter::V1);
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
- $this->assertEquals("1", $message['@version']);
- $this->assertEquals('log', $message['message']);
- $this->assertEquals('meh', $message['channel']);
- $this->assertEquals('ERROR', $message['level']);
- $this->assertEquals('test', $message['type']);
- $this->assertEquals('hostname', $message['host']);
-
- $formatter = new LogstashFormatter('mysystem', null, null, 'ctxt_', LogstashFormatter::V1);
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals('mysystem', $message['type']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithFileAndLineV1()
- {
- $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('file' => 'test', 'line' => 14),
- 'message' => 'log',
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertEquals('test', $message['file']);
- $this->assertEquals(14, $message['line']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithContextV1()
- {
- $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('ctxt_from', $message);
- $this->assertEquals('logger', $message['ctxt_from']);
-
- // Test with extraPrefix
- $formatter = new LogstashFormatter('test', null, null, 'CTX', LogstashFormatter::V1);
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('CTXfrom', $message);
- $this->assertEquals('logger', $message['CTXfrom']);
- }
-
- /**
- * @covers Monolog\Formatter\LogstashFormatter::format
- */
- public function testFormatWithExtraV1()
- {
- $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('key', $message);
- $this->assertEquals('pair', $message['key']);
-
- // Test with extraPrefix
- $formatter = new LogstashFormatter('test', null, 'EXT', 'ctxt_', LogstashFormatter::V1);
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('EXTkey', $message);
- $this->assertEquals('pair', $message['EXTkey']);
- }
-
- public function testFormatWithApplicationNameV1()
- {
- $formatter = new LogstashFormatter('app', 'test', null, 'ctxt_', LogstashFormatter::V1);
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('key' => 'pair'),
- 'message' => 'log'
- );
-
- $message = json_decode($formatter->format($record), true);
-
- $this->assertArrayHasKey('type', $message);
- $this->assertEquals('app', $message['type']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php
deleted file mode 100644
index 1554ef4..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php
+++ /dev/null
@@ -1,253 +0,0 @@
-
- */
-class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- if (!class_exists('MongoDate')) {
- $this->markTestSkipped('mongo extension not installed');
- }
- }
-
- public function constructArgumentProvider()
- {
- return array(
- array(1, true, 1, true),
- array(0, false, 0, false),
- );
- }
-
- /**
- * @param $traceDepth
- * @param $traceAsString
- * @param $expectedTraceDepth
- * @param $expectedTraceAsString
- *
- * @dataProvider constructArgumentProvider
- */
- public function testConstruct($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString)
- {
- $formatter = new MongoDBFormatter($traceDepth, $traceAsString);
-
- $reflTrace = new \ReflectionProperty($formatter, 'exceptionTraceAsString');
- $reflTrace->setAccessible(true);
- $this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter));
-
- $reflDepth = new\ReflectionProperty($formatter, 'maxNestingLevel');
- $reflDepth->setAccessible(true);
- $this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter));
- }
-
- public function testSimpleFormat()
- {
- $record = array(
- 'message' => 'some log message',
- 'context' => array(),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter();
- $formattedRecord = $formatter->format($record);
-
- $this->assertCount(7, $formattedRecord);
- $this->assertEquals('some log message', $formattedRecord['message']);
- $this->assertEquals(array(), $formattedRecord['context']);
- $this->assertEquals(Logger::WARNING, $formattedRecord['level']);
- $this->assertEquals(Logger::getLevelName(Logger::WARNING), $formattedRecord['level_name']);
- $this->assertEquals('test', $formattedRecord['channel']);
- $this->assertInstanceOf('\MongoDate', $formattedRecord['datetime']);
- $this->assertEquals('0.00000000 1391212800', $formattedRecord['datetime']->__toString());
- $this->assertEquals(array(), $formattedRecord['extra']);
- }
-
- public function testRecursiveFormat()
- {
- $someObject = new \stdClass();
- $someObject->foo = 'something';
- $someObject->bar = 'stuff';
-
- $record = array(
- 'message' => 'some log message',
- 'context' => array(
- 'stuff' => new \DateTime('2014-02-01 02:31:33'),
- 'some_object' => $someObject,
- 'context_string' => 'some string',
- 'context_int' => 123456,
- 'except' => new \Exception('exception message', 987),
- ),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter();
- $formattedRecord = $formatter->format($record);
-
- $this->assertCount(5, $formattedRecord['context']);
- $this->assertInstanceOf('\MongoDate', $formattedRecord['context']['stuff']);
- $this->assertEquals('0.00000000 1391221893', $formattedRecord['context']['stuff']->__toString());
- $this->assertEquals(
- array(
- 'foo' => 'something',
- 'bar' => 'stuff',
- 'class' => 'stdClass',
- ),
- $formattedRecord['context']['some_object']
- );
- $this->assertEquals('some string', $formattedRecord['context']['context_string']);
- $this->assertEquals(123456, $formattedRecord['context']['context_int']);
-
- $this->assertCount(5, $formattedRecord['context']['except']);
- $this->assertEquals('exception message', $formattedRecord['context']['except']['message']);
- $this->assertEquals(987, $formattedRecord['context']['except']['code']);
- $this->assertInternalType('string', $formattedRecord['context']['except']['file']);
- $this->assertInternalType('integer', $formattedRecord['context']['except']['code']);
- $this->assertInternalType('string', $formattedRecord['context']['except']['trace']);
- $this->assertEquals('Exception', $formattedRecord['context']['except']['class']);
- }
-
- public function testFormatDepthArray()
- {
- $record = array(
- 'message' => 'some log message',
- 'context' => array(
- 'nest2' => array(
- 'property' => 'anything',
- 'nest3' => array(
- 'nest4' => 'value',
- 'property' => 'nothing'
- )
- )
- ),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter(2);
- $formattedResult = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'nest2' => array(
- 'property' => 'anything',
- 'nest3' => '[...]',
- )
- ),
- $formattedResult['context']
- );
- }
-
- public function testFormatDepthArrayInfiniteNesting()
- {
- $record = array(
- 'message' => 'some log message',
- 'context' => array(
- 'nest2' => array(
- 'property' => 'something',
- 'nest3' => array(
- 'property' => 'anything',
- 'nest4' => array(
- 'property' => 'nothing',
- ),
- )
- )
- ),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter(0);
- $formattedResult = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'nest2' => array(
- 'property' => 'something',
- 'nest3' => array(
- 'property' => 'anything',
- 'nest4' => array(
- 'property' => 'nothing',
- )
- ),
- )
- ),
- $formattedResult['context']
- );
- }
-
- public function testFormatDepthObjects()
- {
- $someObject = new \stdClass();
- $someObject->property = 'anything';
- $someObject->nest3 = new \stdClass();
- $someObject->nest3->property = 'nothing';
- $someObject->nest3->nest4 = 'invisible';
-
- $record = array(
- 'message' => 'some log message',
- 'context' => array(
- 'nest2' => $someObject
- ),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter(2, true);
- $formattedResult = $formatter->format($record);
-
- $this->assertEquals(
- array(
- 'nest2' => array(
- 'property' => 'anything',
- 'nest3' => '[...]',
- 'class' => 'stdClass',
- ),
- ),
- $formattedResult['context']
- );
- }
-
- public function testFormatDepthException()
- {
- $record = array(
- 'message' => 'some log message',
- 'context' => array(
- 'nest2' => new \Exception('exception message', 987),
- ),
- 'level' => Logger::WARNING,
- 'level_name' => Logger::getLevelName(Logger::WARNING),
- 'channel' => 'test',
- 'datetime' => new \DateTime('2014-02-01 00:00:00'),
- 'extra' => array(),
- );
-
- $formatter = new MongoDBFormatter(2, false);
- $formattedRecord = $formatter->format($record);
-
- $this->assertEquals('exception message', $formattedRecord['context']['nest2']['message']);
- $this->assertEquals(987, $formattedRecord['context']['nest2']['code']);
- $this->assertEquals('[...]', $formattedRecord['context']['nest2']['trace']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
deleted file mode 100644
index c484dfe..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
+++ /dev/null
@@ -1,270 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-/**
- * @covers Monolog\Formatter\NormalizerFormatter
- */
-class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
-{
- public function testFormat()
- {
- $formatter = new NormalizerFormatter('Y-m-d');
- $formatted = $formatter->format(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'message' => 'foo',
- 'datetime' => new \DateTime,
- 'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
- 'context' => array(
- 'foo' => 'bar',
- 'baz' => 'qux',
- 'inf' => INF,
- '-inf' => -INF,
- 'nan' => acos(4),
- ),
- ));
-
- $this->assertEquals(array(
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'message' => 'foo',
- 'datetime' => date('Y-m-d'),
- 'extra' => array(
- 'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
- 'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
- 'baz' => array(),
- 'res' => '[resource] (stream)',
- ),
- 'context' => array(
- 'foo' => 'bar',
- 'baz' => 'qux',
- 'inf' => 'INF',
- '-inf' => '-INF',
- 'nan' => 'NaN',
- )
- ), $formatted);
- }
-
- public function testFormatExceptions()
- {
- $formatter = new NormalizerFormatter('Y-m-d');
- $e = new \LogicException('bar');
- $e2 = new \RuntimeException('foo', 0, $e);
- $formatted = $formatter->format(array(
- 'exception' => $e2,
- ));
-
- $this->assertGreaterThan(5, count($formatted['exception']['trace']));
- $this->assertTrue(isset($formatted['exception']['previous']));
- unset($formatted['exception']['trace'], $formatted['exception']['previous']);
-
- $this->assertEquals(array(
- 'exception' => array(
- 'class' => get_class($e2),
- 'message' => $e2->getMessage(),
- 'code' => $e2->getCode(),
- 'file' => $e2->getFile().':'.$e2->getLine(),
- )
- ), $formatted);
- }
-
- public function testBatchFormat()
- {
- $formatter = new NormalizerFormatter('Y-m-d');
- $formatted = $formatter->formatBatch(array(
- array(
- 'level_name' => 'CRITICAL',
- 'channel' => 'test',
- 'message' => 'bar',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- ),
- array(
- 'level_name' => 'WARNING',
- 'channel' => 'log',
- 'message' => 'foo',
- 'context' => array(),
- 'datetime' => new \DateTime,
- 'extra' => array(),
- ),
- ));
- $this->assertEquals(array(
- array(
- 'level_name' => 'CRITICAL',
- 'channel' => 'test',
- 'message' => 'bar',
- 'context' => array(),
- 'datetime' => date('Y-m-d'),
- 'extra' => array(),
- ),
- array(
- 'level_name' => 'WARNING',
- 'channel' => 'log',
- 'message' => 'foo',
- 'context' => array(),
- 'datetime' => date('Y-m-d'),
- 'extra' => array(),
- ),
- ), $formatted);
- }
-
- /**
- * Test issue #137
- */
- public function testIgnoresRecursiveObjectReferences()
- {
- // set up the recursion
- $foo = new \stdClass();
- $bar = new \stdClass();
-
- $foo->bar = $bar;
- $bar->foo = $foo;
-
- // set an error handler to assert that the error is not raised anymore
- $that = $this;
- set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
- if (error_reporting() & $level) {
- restore_error_handler();
- $that->fail("$message should not be raised");
- }
- });
-
- $formatter = new NormalizerFormatter();
- $reflMethod = new \ReflectionMethod($formatter, 'toJson');
- $reflMethod->setAccessible(true);
- $res = $reflMethod->invoke($formatter, array($foo, $bar), true);
-
- restore_error_handler();
-
- $this->assertEquals(@json_encode(array($foo, $bar)), $res);
- }
-
- public function testIgnoresInvalidTypes()
- {
- // set up the recursion
- $resource = fopen(__FILE__, 'r');
-
- // set an error handler to assert that the error is not raised anymore
- $that = $this;
- set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
- if (error_reporting() & $level) {
- restore_error_handler();
- $that->fail("$message should not be raised");
- }
- });
-
- $formatter = new NormalizerFormatter();
- $reflMethod = new \ReflectionMethod($formatter, 'toJson');
- $reflMethod->setAccessible(true);
- $res = $reflMethod->invoke($formatter, array($resource), true);
-
- restore_error_handler();
-
- $this->assertEquals(@json_encode(array($resource)), $res);
- }
-
- /**
- * @expectedException RuntimeException
- */
- public function testThrowsOnInvalidEncoding()
- {
- $formatter = new NormalizerFormatter();
- $reflMethod = new \ReflectionMethod($formatter, 'toJson');
- $reflMethod->setAccessible(true);
-
- // send an invalid unicode sequence
- $res = $reflMethod->invoke($formatter, array('message' => "\xB1\x31"));
- if (PHP_VERSION_ID < 50500 && $res === '{"message":null}') {
- throw new \RuntimeException('PHP 5.3/5.4 throw a warning and null the value instead of returning false entirely');
- }
- }
-
- public function testExceptionTraceWithArgs()
- {
- if (defined('HHVM_VERSION')) {
- $this->markTestSkipped('Not supported in HHVM since it detects errors differently');
- }
-
- // This happens i.e. in React promises or Guzzle streams where stream wrappers are registered
- // and no file or line are included in the trace because it's treated as internal function
- set_error_handler(function ($errno, $errstr, $errfile, $errline) {
- throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
- });
-
- try {
- // This will contain $resource and $wrappedResource as arguments in the trace item
- $resource = fopen('php://memory', 'rw+');
- fwrite($resource, 'test_resource');
- $wrappedResource = new TestFooNorm;
- $wrappedResource->foo = $resource;
- // Just do something stupid with a resource/wrapped resource as argument
- array_keys($wrappedResource);
- } catch (\Exception $e) {
- restore_error_handler();
- }
-
- $formatter = new NormalizerFormatter();
- $record = array('context' => array('exception' => $e));
- $result = $formatter->format($record);
-
- $this->assertRegExp(
- '%"resource":"\[resource\] \(stream\)"%',
- $result['context']['exception']['trace'][0]
- );
-
- if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
- $pattern = '%"wrappedResource":"\[object\] \(Monolog\\\\\\\\Formatter\\\\\\\\TestFooNorm: \)"%';
- } else {
- $pattern = '%\\\\"foo\\\\":null%';
- }
-
- // Tests that the wrapped resource is ignored while encoding, only works for PHP <= 5.4
- $this->assertRegExp(
- $pattern,
- $result['context']['exception']['trace'][0]
- );
- }
-}
-
-class TestFooNorm
-{
- public $foo = 'foo';
-}
-
-class TestBarNorm
-{
- public function __toString()
- {
- return 'bar';
- }
-}
-
-class TestStreamFoo
-{
- public $foo;
- public $resource;
-
- public function __construct($resource)
- {
- $this->resource = $resource;
- $this->foo = 'BAR';
- }
-
- public function __toString()
- {
- fseek($this->resource, 0);
-
- return $this->foo . ' - ' . (string) stream_get_contents($this->resource);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php
deleted file mode 100644
index 2a35446..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php
+++ /dev/null
@@ -1,100 +0,0 @@
-formatter = new ScalarFormatter();
- }
-
- public function buildTrace(\Exception $e)
- {
- $data = array();
- $trace = $e->getTrace();
- foreach ($trace as $frame) {
- if (isset($frame['file'])) {
- $data[] = $frame['file'].':'.$frame['line'];
- } else {
- $data[] = json_encode($frame);
- }
- }
-
- return $data;
- }
-
- public function encodeJson($data)
- {
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
- }
-
- return json_encode($data);
- }
-
- public function testFormat()
- {
- $exception = new \Exception('foo');
- $formatted = $this->formatter->format(array(
- 'foo' => 'string',
- 'bar' => 1,
- 'baz' => false,
- 'bam' => array(1, 2, 3),
- 'bat' => array('foo' => 'bar'),
- 'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
- 'ban' => $exception
- ));
-
- $this->assertSame(array(
- 'foo' => 'string',
- 'bar' => 1,
- 'baz' => false,
- 'bam' => $this->encodeJson(array(1, 2, 3)),
- 'bat' => $this->encodeJson(array('foo' => 'bar')),
- 'bap' => '1970-01-01 00:00:00',
- 'ban' => $this->encodeJson(array(
- 'class' => get_class($exception),
- 'message' => $exception->getMessage(),
- 'code' => $exception->getCode(),
- 'file' => $exception->getFile() . ':' . $exception->getLine(),
- 'trace' => $this->buildTrace($exception)
- ))
- ), $formatted);
- }
-
- public function testFormatWithErrorContext()
- {
- $context = array('file' => 'foo', 'line' => 1);
- $formatted = $this->formatter->format(array(
- 'context' => $context
- ));
-
- $this->assertSame(array(
- 'context' => $this->encodeJson($context)
- ), $formatted);
- }
-
- public function testFormatWithExceptionContext()
- {
- $exception = new \Exception('foo');
- $formatted = $this->formatter->format(array(
- 'context' => array(
- 'exception' => $exception
- )
- ));
-
- $this->assertSame(array(
- 'context' => $this->encodeJson(array(
- 'exception' => array(
- 'class' => get_class($exception),
- 'message' => $exception->getMessage(),
- 'code' => $exception->getCode(),
- 'file' => $exception->getFile() . ':' . $exception->getLine(),
- 'trace' => $this->buildTrace($exception)
- )
- ))
- ), $formatted);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php b/application/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
deleted file mode 100644
index 52f15a3..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
+++ /dev/null
@@ -1,142 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Formatter;
-
-use Monolog\Logger;
-
-class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @covers Monolog\Formatter\WildfireFormatter::format
- */
- public function testDefaultFormat()
- {
- $wildfire = new WildfireFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('ip' => '127.0.0.1'),
- 'message' => 'log',
- );
-
- $message = $wildfire->format($record);
-
- $this->assertEquals(
- '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},'
- .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\WildfireFormatter::format
- */
- public function testFormatWithFileAndLine()
- {
- $wildfire = new WildfireFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('from' => 'logger'),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
- 'message' => 'log',
- );
-
- $message = $wildfire->format($record);
-
- $this->assertEquals(
- '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},'
- .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\WildfireFormatter::format
- */
- public function testFormatWithoutContext()
- {
- $wildfire = new WildfireFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $message = $wildfire->format($record);
-
- $this->assertEquals(
- '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|',
- $message
- );
- }
-
- /**
- * @covers Monolog\Formatter\WildfireFormatter::formatBatch
- * @expectedException BadMethodCallException
- */
- public function testBatchFormatThrowException()
- {
- $wildfire = new WildfireFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array(),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $wildfire->formatBatch(array($record));
- }
-
- /**
- * @covers Monolog\Formatter\WildfireFormatter::format
- */
- public function testTableFormat()
- {
- $wildfire = new WildfireFormatter();
- $record = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'table-channel',
- 'context' => array(
- WildfireFormatter::TABLE => array(
- array('col1', 'col2', 'col3'),
- array('val1', 'val2', 'val3'),
- array('foo1', 'foo2', 'foo3'),
- array('bar1', 'bar2', 'bar3'),
- ),
- ),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'table-message',
- );
-
- $message = $wildfire->format($record);
-
- $this->assertEquals(
- '171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|',
- $message
- );
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
deleted file mode 100644
index 568eb9d..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\LineFormatter;
-use Monolog\Processor\WebProcessor;
-
-class AbstractHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\AbstractHandler::__construct
- * @covers Monolog\Handler\AbstractHandler::getLevel
- * @covers Monolog\Handler\AbstractHandler::setLevel
- * @covers Monolog\Handler\AbstractHandler::getBubble
- * @covers Monolog\Handler\AbstractHandler::setBubble
- * @covers Monolog\Handler\AbstractHandler::getFormatter
- * @covers Monolog\Handler\AbstractHandler::setFormatter
- */
- public function testConstructAndGetSet()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
- $this->assertEquals(Logger::WARNING, $handler->getLevel());
- $this->assertEquals(false, $handler->getBubble());
-
- $handler->setLevel(Logger::ERROR);
- $handler->setBubble(true);
- $handler->setFormatter($formatter = new LineFormatter);
- $this->assertEquals(Logger::ERROR, $handler->getLevel());
- $this->assertEquals(true, $handler->getBubble());
- $this->assertSame($formatter, $handler->getFormatter());
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::handleBatch
- */
- public function testHandleBatch()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
- $handler->expects($this->exactly(2))
- ->method('handle');
- $handler->handleBatch(array($this->getRecord(), $this->getRecord()));
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::isHandling
- */
- public function testIsHandling()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
- $this->assertTrue($handler->isHandling($this->getRecord()));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::__construct
- */
- public function testHandlesPsrStyleLevels()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array('warning', false));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
- $handler->setLevel('debug');
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::getFormatter
- * @covers Monolog\Handler\AbstractHandler::getDefaultFormatter
- */
- public function testGetFormatterInitializesDefault()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
- $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter());
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::pushProcessor
- * @covers Monolog\Handler\AbstractHandler::popProcessor
- * @expectedException LogicException
- */
- public function testPushPopProcessor()
- {
- $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
- $processor1 = new WebProcessor;
- $processor2 = new WebProcessor;
-
- $logger->pushProcessor($processor1);
- $logger->pushProcessor($processor2);
-
- $this->assertEquals($processor2, $logger->popProcessor());
- $this->assertEquals($processor1, $logger->popProcessor());
- $logger->popProcessor();
- }
-
- /**
- * @covers Monolog\Handler\AbstractHandler::pushProcessor
- * @expectedException InvalidArgumentException
- */
- public function testPushProcessorWithNonCallable()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
-
- $handler->pushProcessor(new \stdClass());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
deleted file mode 100644
index 24d4f63..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Processor\WebProcessor;
-
-class AbstractProcessingHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\AbstractProcessingHandler::handle
- */
- public function testHandleLowerLevelMessage()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
- $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\AbstractProcessingHandler::handle
- */
- public function testHandleBubbling()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
- $this->assertFalse($handler->handle($this->getRecord()));
- }
-
- /**
- * @covers Monolog\Handler\AbstractProcessingHandler::handle
- */
- public function testHandleNotBubbling()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
- $this->assertTrue($handler->handle($this->getRecord()));
- }
-
- /**
- * @covers Monolog\Handler\AbstractProcessingHandler::handle
- */
- public function testHandleIsFalseWhenNotHandled()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
- $this->assertTrue($handler->handle($this->getRecord()));
- $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
- */
- public function testProcessRecord()
- {
- $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
- $handler->pushProcessor(new WebProcessor(array(
- 'REQUEST_URI' => '',
- 'REQUEST_METHOD' => '',
- 'REMOTE_ADDR' => '',
- 'SERVER_NAME' => '',
- 'UNIQUE_ID' => '',
- )));
- $handledRecord = null;
- $handler->expects($this->once())
- ->method('write')
- ->will($this->returnCallback(function ($record) use (&$handledRecord) {
- $handledRecord = $record;
- }))
- ;
- $handler->handle($this->getRecord());
- $this->assertEquals(6, count($handledRecord['extra']));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
deleted file mode 100644
index a71d625..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use PhpAmqpLib\Message\AMQPMessage;
-use PhpAmqpLib\Connection\AMQPConnection;
-
-/**
- * @covers Monolog\Handler\RotatingFileHandler
- */
-class AmqpHandlerTest extends TestCase
-{
- public function testHandleAmqpExt()
- {
- if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) {
- $this->markTestSkipped("amqp-php not installed");
- }
-
- if (!class_exists('AMQPChannel')) {
- $this->markTestSkipped("Please update AMQP to version >= 1.0");
- }
-
- $messages = array();
-
- $exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
- $exchange->expects($this->once())
- ->method('setName')
- ->with('log')
- ;
- $exchange->expects($this->any())
- ->method('publish')
- ->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) {
- $messages[] = array($message, $routing_key, $flags, $attributes);
- }))
- ;
-
- $handler = new AmqpHandler($exchange, 'log');
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $expected = array(
- array(
- 'message' => 'test',
- 'context' => array(
- 'data' => array(),
- 'foo' => 34,
- ),
- 'level' => 300,
- 'level_name' => 'WARNING',
- 'channel' => 'test',
- 'extra' => array(),
- ),
- 'warn.test',
- 0,
- array(
- 'delivery_mode' => 2,
- 'Content-type' => 'application/json'
- )
- );
-
- $handler->handle($record);
-
- $this->assertCount(1, $messages);
- $messages[0][0] = json_decode($messages[0][0], true);
- unset($messages[0][0]['datetime']);
- $this->assertEquals($expected, $messages[0]);
- }
-
- public function testHandlePhpAmqpLib()
- {
- if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) {
- $this->markTestSkipped("php-amqplib not installed");
- }
-
- $messages = array();
-
- $exchange = $this->getMock('PhpAmqpLib\Channel\AMQPChannel', array('basic_publish', '__destruct'), array(), '', false);
-
- $exchange->expects($this->any())
- ->method('basic_publish')
- ->will($this->returnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) {
- $messages[] = array($msg, $exchange, $routing_key, $mandatory, $immediate, $ticket);
- }))
- ;
-
- $handler = new AmqpHandler($exchange, 'log');
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $expected = array(
- array(
- 'message' => 'test',
- 'context' => array(
- 'data' => array(),
- 'foo' => 34,
- ),
- 'level' => 300,
- 'level_name' => 'WARNING',
- 'channel' => 'test',
- 'extra' => array(),
- ),
- 'log',
- 'warn.test',
- false,
- false,
- null,
- array(
- 'delivery_mode' => 2,
- 'content_type' => 'application/json'
- )
- );
-
- $handler->handle($record);
-
- $this->assertCount(1, $messages);
-
- /* @var $msg AMQPMessage */
- $msg = $messages[0][0];
- $messages[0][0] = json_decode($msg->body, true);
- $messages[0][] = $msg->get_properties();
- unset($messages[0][0]['datetime']);
-
- $this->assertEquals($expected, $messages[0]);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
deleted file mode 100644
index ffb1d74..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
+++ /dev/null
@@ -1,130 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\BrowserConsoleHandlerTest
- */
-class BrowserConsoleHandlerTest extends TestCase
-{
- protected function setUp()
- {
- BrowserConsoleHandler::reset();
- }
-
- protected function generateScript()
- {
- $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript');
- $reflMethod->setAccessible(true);
-
- return $reflMethod->invoke(null);
- }
-
- public function testStyling()
- {
- $handler = new BrowserConsoleHandler();
- $handler->setFormatter($this->getIdentityFormatter());
-
- $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
-
- $expected = <<assertEquals($expected, $this->generateScript());
- }
-
- public function testEscaping()
- {
- $handler = new BrowserConsoleHandler();
- $handler->setFormatter($this->getIdentityFormatter());
-
- $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
-
- $expected = <<assertEquals($expected, $this->generateScript());
- }
-
- public function testAutolabel()
- {
- $handler = new BrowserConsoleHandler();
- $handler->setFormatter($this->getIdentityFormatter());
-
- $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
- $handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}'));
- $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
-
- $expected = <<assertEquals($expected, $this->generateScript());
- }
-
- public function testContext()
- {
- $handler = new BrowserConsoleHandler();
- $handler->setFormatter($this->getIdentityFormatter());
-
- $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
-
- $expected = <<assertEquals($expected, $this->generateScript());
- }
-
- public function testConcurrentHandlers()
- {
- $handler1 = new BrowserConsoleHandler();
- $handler1->setFormatter($this->getIdentityFormatter());
-
- $handler2 = new BrowserConsoleHandler();
- $handler2->setFormatter($this->getIdentityFormatter());
-
- $handler1->handle($this->getRecord(Logger::DEBUG, 'test1'));
- $handler2->handle($this->getRecord(Logger::DEBUG, 'test2'));
- $handler1->handle($this->getRecord(Logger::DEBUG, 'test3'));
- $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
-
- $expected = <<assertEquals($expected, $this->generateScript());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
deleted file mode 100644
index da8b3c3..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
+++ /dev/null
@@ -1,158 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class BufferHandlerTest extends TestCase
-{
- private $shutdownCheckHandler;
-
- /**
- * @covers Monolog\Handler\BufferHandler::__construct
- * @covers Monolog\Handler\BufferHandler::handle
- * @covers Monolog\Handler\BufferHandler::close
- */
- public function testHandleBuffers()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertFalse($test->hasDebugRecords());
- $this->assertFalse($test->hasInfoRecords());
- $handler->close();
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 2);
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::close
- * @covers Monolog\Handler\BufferHandler::flush
- */
- public function testPropagatesRecordsAtEndOfRequest()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test);
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->shutdownCheckHandler = $test;
- register_shutdown_function(array($this, 'checkPropagation'));
- }
-
- public function checkPropagation()
- {
- if (!$this->shutdownCheckHandler->hasWarningRecords() || !$this->shutdownCheckHandler->hasDebugRecords()) {
- echo '!!! BufferHandlerTest::testPropagatesRecordsAtEndOfRequest failed to verify that the messages have been propagated' . PHP_EOL;
- exit(1);
- }
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::handle
- */
- public function testHandleBufferLimit()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test, 2);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->close();
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertFalse($test->hasDebugRecords());
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::handle
- */
- public function testHandleBufferLimitWithFlushOnOverflow()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
-
- // send two records
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->assertFalse($test->hasDebugRecords());
- $this->assertCount(0, $test->getRecords());
-
- // overflow
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertTrue($test->hasDebugRecords());
- $this->assertCount(3, $test->getRecords());
-
- // should buffer again
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertCount(3, $test->getRecords());
-
- $handler->close();
- $this->assertCount(5, $test->getRecords());
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasInfoRecords());
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::handle
- */
- public function testHandleLevel()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test, 0, Logger::INFO);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->close();
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertFalse($test->hasDebugRecords());
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::flush
- */
- public function testFlush()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test, 0);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->flush();
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue($test->hasDebugRecords());
- $this->assertFalse($test->hasWarningRecords());
- }
-
- /**
- * @covers Monolog\Handler\BufferHandler::handle
- */
- public function testHandleUsesProcessors()
- {
- $test = new TestHandler();
- $handler = new BufferHandler($test);
- $handler->pushProcessor(function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->flush();
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
deleted file mode 100644
index 4d64025..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\ChromePHPHandler
- */
-class ChromePHPHandlerTest extends TestCase
-{
- protected function setUp()
- {
- TestChromePHPHandler::reset();
- $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
- }
-
- public function testHeaders()
- {
- $handler = new TestChromePHPHandler();
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING));
-
- $expected = array(
- 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
- 'version' => ChromePHPHandler::VERSION,
- 'columns' => array('label', 'log', 'backtrace', 'type'),
- 'rows' => array(
- 'test',
- 'test',
- ),
- 'request_uri' => '',
- ))))
- );
-
- $this->assertEquals($expected, $handler->getHeaders());
- }
-
- public function testHeadersOverflow()
- {
- $handler = new TestChromePHPHandler();
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150 * 1024)));
-
- // overflow chrome headers limit
- $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100 * 1024)));
-
- $expected = array(
- 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
- 'version' => ChromePHPHandler::VERSION,
- 'columns' => array('label', 'log', 'backtrace', 'type'),
- 'rows' => array(
- array(
- 'test',
- 'test',
- 'unknown',
- 'log',
- ),
- array(
- 'test',
- str_repeat('a', 150 * 1024),
- 'unknown',
- 'warn',
- ),
- array(
- 'monolog',
- 'Incomplete logs, chrome header size limit reached',
- 'unknown',
- 'warn',
- ),
- ),
- 'request_uri' => '',
- ))))
- );
-
- $this->assertEquals($expected, $handler->getHeaders());
- }
-
- public function testConcurrentHandlers()
- {
- $handler = new TestChromePHPHandler();
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING));
-
- $handler2 = new TestChromePHPHandler();
- $handler2->setFormatter($this->getIdentityFormatter());
- $handler2->handle($this->getRecord(Logger::DEBUG));
- $handler2->handle($this->getRecord(Logger::WARNING));
-
- $expected = array(
- 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
- 'version' => ChromePHPHandler::VERSION,
- 'columns' => array('label', 'log', 'backtrace', 'type'),
- 'rows' => array(
- 'test',
- 'test',
- 'test',
- 'test',
- ),
- 'request_uri' => '',
- ))))
- );
-
- $this->assertEquals($expected, $handler2->getHeaders());
- }
-}
-
-class TestChromePHPHandler extends ChromePHPHandler
-{
- protected $headers = array();
-
- public static function reset()
- {
- self::$initialized = false;
- self::$overflowed = false;
- self::$sendHeaders = true;
- self::$json['rows'] = array();
- }
-
- protected function sendHeader($header, $content)
- {
- $this->headers[$header] = $content;
- }
-
- public function getHeaders()
- {
- return $this->headers;
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
deleted file mode 100644
index 9fc4b38..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class CouchDBHandlerTest extends TestCase
-{
- public function testHandle()
- {
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $handler = new CouchDBHandler();
-
- try {
- $handler->handle($record);
- } catch (\RuntimeException $e) {
- $this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984');
- }
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
deleted file mode 100644
index d67da90..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class DoctrineCouchDBHandlerTest extends TestCase
-{
- protected function setup()
- {
- if (!class_exists('Doctrine\CouchDB\CouchDBClient')) {
- $this->markTestSkipped('The "doctrine/couchdb" package is not installed');
- }
- }
-
- public function testHandle()
- {
- $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
- ->setMethods(array('postDocument'))
- ->disableOriginalConstructor()
- ->getMock();
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $expected = array(
- 'message' => 'test',
- 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
- 'level' => Logger::WARNING,
- 'level_name' => 'WARNING',
- 'channel' => 'test',
- 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
- 'extra' => array(),
- );
-
- $client->expects($this->once())
- ->method('postDocument')
- ->with($expected);
-
- $handler = new DoctrineCouchDBHandler($client);
- $handler->handle($record);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php
deleted file mode 100644
index 42d4323..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php
+++ /dev/null
@@ -1,75 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-
-class DynamoDbHandlerTest extends TestCase
-{
- private $client;
-
- public function setUp()
- {
- if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
- $this->markTestSkipped('aws/aws-sdk-php not installed');
- }
-
- $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
- ->setMethods(array('formatAttributes', '__call'))
- ->disableOriginalConstructor()->getMock();
- }
-
- public function testConstruct()
- {
- $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
- }
-
- public function testInterface()
- {
- $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
- }
-
- public function testGetFormatter()
- {
- $handler = new DynamoDbHandler($this->client, 'foo');
- $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
- }
-
- public function testHandle()
- {
- $record = $this->getRecord();
- $formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
- $formatted = array('foo' => 1, 'bar' => 2);
- $handler = new DynamoDbHandler($this->client, 'foo');
- $handler->setFormatter($formatter);
-
- $formatter
- ->expects($this->once())
- ->method('format')
- ->with($record)
- ->will($this->returnValue($formatted));
- $this->client
- ->expects($this->once())
- ->method('formatAttributes')
- ->with($this->isType('array'))
- ->will($this->returnValue($formatted));
- $this->client
- ->expects($this->once())
- ->method('__call')
- ->with('putItem', array(array(
- 'TableName' => 'foo',
- 'Item' => $formatted
- )));
-
- $handler->handle($record);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php
deleted file mode 100644
index 1687074..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php
+++ /dev/null
@@ -1,239 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Formatter\ElasticaFormatter;
-use Monolog\Formatter\NormalizerFormatter;
-use Monolog\TestCase;
-use Monolog\Logger;
-use Elastica\Client;
-use Elastica\Request;
-use Elastica\Response;
-
-class ElasticSearchHandlerTest extends TestCase
-{
- /**
- * @var Client mock
- */
- protected $client;
-
- /**
- * @var array Default handler options
- */
- protected $options = array(
- 'index' => 'my_index',
- 'type' => 'doc_type',
- );
-
- public function setUp()
- {
- // Elastica lib required
- if (!class_exists("Elastica\Client")) {
- $this->markTestSkipped("ruflin/elastica not installed");
- }
-
- // base mock Elastica Client object
- $this->client = $this->getMockBuilder('Elastica\Client')
- ->setMethods(array('addDocuments'))
- ->disableOriginalConstructor()
- ->getMock();
- }
-
- /**
- * @covers Monolog\Handler\ElasticSearchHandler::write
- * @covers Monolog\Handler\ElasticSearchHandler::handleBatch
- * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
- * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
- */
- public function testHandle()
- {
- // log message
- $msg = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- // format expected result
- $formatter = new ElasticaFormatter($this->options['index'], $this->options['type']);
- $expected = array($formatter->format($msg));
-
- // setup ES client mock
- $this->client->expects($this->any())
- ->method('addDocuments')
- ->with($expected);
-
- // perform tests
- $handler = new ElasticSearchHandler($this->client, $this->options);
- $handler->handle($msg);
- $handler->handleBatch(array($msg));
- }
-
- /**
- * @covers Monolog\Handler\ElasticSearchHandler::setFormatter
- */
- public function testSetFormatter()
- {
- $handler = new ElasticSearchHandler($this->client);
- $formatter = new ElasticaFormatter('index_new', 'type_new');
- $handler->setFormatter($formatter);
- $this->assertInstanceOf('Monolog\Formatter\ElasticaFormatter', $handler->getFormatter());
- $this->assertEquals('index_new', $handler->getFormatter()->getIndex());
- $this->assertEquals('type_new', $handler->getFormatter()->getType());
- }
-
- /**
- * @covers Monolog\Handler\ElasticSearchHandler::setFormatter
- * @expectedException InvalidArgumentException
- * @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter
- */
- public function testSetFormatterInvalid()
- {
- $handler = new ElasticSearchHandler($this->client);
- $formatter = new NormalizerFormatter();
- $handler->setFormatter($formatter);
- }
-
- /**
- * @covers Monolog\Handler\ElasticSearchHandler::__construct
- * @covers Monolog\Handler\ElasticSearchHandler::getOptions
- */
- public function testOptions()
- {
- $expected = array(
- 'index' => $this->options['index'],
- 'type' => $this->options['type'],
- 'ignore_error' => false,
- );
- $handler = new ElasticSearchHandler($this->client, $this->options);
- $this->assertEquals($expected, $handler->getOptions());
- }
-
- /**
- * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
- * @dataProvider providerTestConnectionErrors
- */
- public function testConnectionErrors($ignore, $expectedError)
- {
- $clientOpts = array('host' => '127.0.0.1', 'port' => 1);
- $client = new Client($clientOpts);
- $handlerOpts = array('ignore_error' => $ignore);
- $handler = new ElasticSearchHandler($client, $handlerOpts);
-
- if ($expectedError) {
- $this->setExpectedException($expectedError[0], $expectedError[1]);
- $handler->handle($this->getRecord());
- } else {
- $this->assertFalse($handler->handle($this->getRecord()));
- }
- }
-
- /**
- * @return array
- */
- public function providerTestConnectionErrors()
- {
- return array(
- array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')),
- array(true, false),
- );
- }
-
- /**
- * Integration test using localhost Elastic Search server
- *
- * @covers Monolog\Handler\ElasticSearchHandler::__construct
- * @covers Monolog\Handler\ElasticSearchHandler::handleBatch
- * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
- * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
- */
- public function testHandleIntegration()
- {
- $msg = array(
- 'level' => Logger::ERROR,
- 'level_name' => 'ERROR',
- 'channel' => 'meh',
- 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
- 'datetime' => new \DateTime("@0"),
- 'extra' => array(),
- 'message' => 'log',
- );
-
- $expected = $msg;
- $expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601);
- $expected['context'] = array(
- 'class' => '[object] (stdClass: {})',
- 'foo' => 7,
- 0 => 'bar',
- );
-
- $client = new Client();
- $handler = new ElasticSearchHandler($client, $this->options);
- try {
- $handler->handleBatch(array($msg));
- } catch (\RuntimeException $e) {
- $this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
- }
-
- // check document id from ES server response
- $documentId = $this->getCreatedDocId($client->getLastResponse());
- $this->assertNotEmpty($documentId, 'No elastic document id received');
-
- // retrieve document source from ES and validate
- $document = $this->getDocSourceFromElastic(
- $client,
- $this->options['index'],
- $this->options['type'],
- $documentId
- );
- $this->assertEquals($expected, $document);
-
- // remove test index from ES
- $client->request("/{$this->options['index']}", Request::DELETE);
- }
-
- /**
- * Return last created document id from ES response
- * @param Response $response Elastica Response object
- * @return string|null
- */
- protected function getCreatedDocId(Response $response)
- {
- $data = $response->getData();
- if (!empty($data['items'][0]['create']['_id'])) {
- return $data['items'][0]['create']['_id'];
- }
- }
-
- /**
- * Retrieve document by id from Elasticsearch
- * @param Client $client Elastica client
- * @param string $index
- * @param string $type
- * @param string $documentId
- * @return array
- */
- protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
- {
- $resp = $client->request("/{$index}/{$type}/{$documentId}", Request::GET);
- $data = $resp->getData();
- if (!empty($data['_source'])) {
- return $data['_source'];
- }
-
- return array();
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php
deleted file mode 100644
index 99785cb..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\LineFormatter;
-
-function error_log()
-{
- $GLOBALS['error_log'][] = func_get_args();
-}
-
-class ErrorLogHandlerTest extends TestCase
-{
- protected function setUp()
- {
- $GLOBALS['error_log'] = array();
- }
-
- /**
- * @covers Monolog\Handler\ErrorLogHandler::__construct
- * @expectedException InvalidArgumentException
- * @expectedExceptionMessage The given message type "42" is not supported
- */
- public function testShouldNotAcceptAnInvalidTypeOnContructor()
- {
- new ErrorLogHandler(42);
- }
-
- /**
- * @covers Monolog\Handler\ErrorLogHandler::write
- */
- public function testShouldLogMessagesUsingErrorLogFuncion()
- {
- $type = ErrorLogHandler::OPERATING_SYSTEM;
- $handler = new ErrorLogHandler($type);
- $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
- $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
-
- $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
- $this->assertSame($GLOBALS['error_log'][0][1], $type);
-
- $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
- $handler->setFormatter(new LineFormatter(null, null, true));
- $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
-
- $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
- $this->assertSame($GLOBALS['error_log'][1][1], $type);
-
- $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
- $this->assertSame($GLOBALS['error_log'][2][1], $type);
-
- $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
- $this->assertSame($GLOBALS['error_log'][3][1], $type);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php
deleted file mode 100644
index 31b7686..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php
+++ /dev/null
@@ -1,170 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Logger;
-use Monolog\TestCase;
-
-class FilterHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\FilterHandler::isHandling
- */
- public function testIsHandling()
- {
- $test = new TestHandler();
- $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE);
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::INFO)));
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::NOTICE)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::WARNING)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::ERROR)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::CRITICAL)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::ALERT)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::EMERGENCY)));
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::handle
- * @covers Monolog\Handler\FilterHandler::setAcceptedLevels
- * @covers Monolog\Handler\FilterHandler::isHandling
- */
- public function testHandleProcessOnlyNeededLevels()
- {
- $test = new TestHandler();
- $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE);
-
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->assertFalse($test->hasDebugRecords());
-
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertTrue($test->hasInfoRecords());
- $handler->handle($this->getRecord(Logger::NOTICE));
- $this->assertTrue($test->hasNoticeRecords());
-
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertFalse($test->hasWarningRecords());
- $handler->handle($this->getRecord(Logger::ERROR));
- $this->assertFalse($test->hasErrorRecords());
- $handler->handle($this->getRecord(Logger::CRITICAL));
- $this->assertFalse($test->hasCriticalRecords());
- $handler->handle($this->getRecord(Logger::ALERT));
- $this->assertFalse($test->hasAlertRecords());
- $handler->handle($this->getRecord(Logger::EMERGENCY));
- $this->assertFalse($test->hasEmergencyRecords());
-
- $test = new TestHandler();
- $handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR));
-
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->assertFalse($test->hasDebugRecords());
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertTrue($test->hasInfoRecords());
- $handler->handle($this->getRecord(Logger::NOTICE));
- $this->assertFalse($test->hasNoticeRecords());
- $handler->handle($this->getRecord(Logger::ERROR));
- $this->assertTrue($test->hasErrorRecords());
- $handler->handle($this->getRecord(Logger::CRITICAL));
- $this->assertFalse($test->hasCriticalRecords());
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::setAcceptedLevels
- * @covers Monolog\Handler\FilterHandler::getAcceptedLevels
- */
- public function testAcceptedLevelApi()
- {
- $test = new TestHandler();
- $handler = new FilterHandler($test);
-
- $levels = array(Logger::INFO, Logger::ERROR);
- $handler->setAcceptedLevels($levels);
- $this->assertSame($levels, $handler->getAcceptedLevels());
-
- $handler->setAcceptedLevels(array('info', 'error'));
- $this->assertSame($levels, $handler->getAcceptedLevels());
-
- $levels = array(Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
- $handler->setAcceptedLevels(Logger::CRITICAL, Logger::EMERGENCY);
- $this->assertSame($levels, $handler->getAcceptedLevels());
-
- $handler->setAcceptedLevels('critical', 'emergency');
- $this->assertSame($levels, $handler->getAcceptedLevels());
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::handle
- */
- public function testHandleUsesProcessors()
- {
- $test = new TestHandler();
- $handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY);
- $handler->pushProcessor(
- function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- }
- );
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::handle
- */
- public function testHandleRespectsBubble()
- {
- $test = new TestHandler();
-
- $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, false);
- $this->assertTrue($handler->handle($this->getRecord(Logger::INFO)));
- $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
-
- $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, true);
- $this->assertFalse($handler->handle($this->getRecord(Logger::INFO)));
- $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::handle
- */
- public function testHandleWithCallback()
- {
- $test = new TestHandler();
- $handler = new FilterHandler(
- function ($record, $handler) use ($test) {
- return $test;
- }, Logger::INFO, Logger::NOTICE, false
- );
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertFalse($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- }
-
- /**
- * @covers Monolog\Handler\FilterHandler::handle
- * @expectedException \RuntimeException
- */
- public function testHandleWithBadCallbackThrowsException()
- {
- $handler = new FilterHandler(
- function ($record, $handler) {
- return 'foo';
- }
- );
- $handler->handle($this->getRecord(Logger::WARNING));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
deleted file mode 100644
index 8e31e9b..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
+++ /dev/null
@@ -1,255 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
-use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
-use Psr\Log\LogLevel;
-
-class FingersCrossedHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::__construct
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleBuffers()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertFalse($test->hasDebugRecords());
- $this->assertFalse($test->hasInfoRecords());
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->close();
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 3);
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleStopsBufferingAfterTrigger()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test);
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->close();
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasDebugRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- * @covers Monolog\Handler\FingersCrossedHandler::reset
- */
- public function testHandleRestartBufferingAfterReset()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test);
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->reset();
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->close();
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasDebugRecords());
- $this->assertFalse($test->hasInfoRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->close();
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasDebugRecords());
- $this->assertFalse($test->hasInfoRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleBufferLimit()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertFalse($test->hasDebugRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleWithCallback()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler(function ($record, $handler) use ($test) {
- return $test;
- });
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $this->assertFalse($test->hasDebugRecords());
- $this->assertFalse($test->hasInfoRecords());
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 3);
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- * @expectedException RuntimeException
- */
- public function testHandleWithBadCallbackThrowsException()
- {
- $handler = new FingersCrossedHandler(function ($record, $handler) {
- return 'foo';
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::isHandling
- */
- public function testIsHandlingAlways()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, Logger::ERROR);
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::__construct
- * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct
- * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated
- */
- public function testErrorLevelActivationStrategy()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->assertFalse($test->hasDebugRecords());
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasWarningRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::__construct
- * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct
- * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated
- */
- public function testErrorLevelActivationStrategyWithPsrLevel()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy('warning'));
- $handler->handle($this->getRecord(Logger::DEBUG));
- $this->assertFalse($test->hasDebugRecords());
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasWarningRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct
- * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated
- */
- public function testChannelLevelActivationStrategy()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG)));
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertFalse($test->hasWarningRecords());
- $record = $this->getRecord(Logger::DEBUG);
- $record['channel'] = 'othertest';
- $handler->handle($record);
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasWarningRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct
- * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated
- */
- public function testChannelLevelActivationStrategyWithPsrLevels()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy('error', array('othertest' => 'debug')));
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertFalse($test->hasWarningRecords());
- $record = $this->getRecord(Logger::DEBUG);
- $record['channel'] = 'othertest';
- $handler->handle($record);
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasWarningRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::handle
- */
- public function testHandleUsesProcessors()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, Logger::INFO);
- $handler->pushProcessor(function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::close
- */
- public function testPassthruOnClose()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, Logger::INFO);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->close();
- $this->assertFalse($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- }
-
- /**
- * @covers Monolog\Handler\FingersCrossedHandler::close
- */
- public function testPsrLevelPassthruOnClose()
- {
- $test = new TestHandler();
- $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, LogLevel::INFO);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- $handler->close();
- $this->assertFalse($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
deleted file mode 100644
index 0eb10a6..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\FirePHPHandler
- */
-class FirePHPHandlerTest extends TestCase
-{
- public function setUp()
- {
- TestFirePHPHandler::reset();
- $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0';
- }
-
- public function testHeaders()
- {
- $handler = new TestFirePHPHandler;
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING));
-
- $expected = array(
- 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
- 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
- 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
- 'X-Wf-1-1-1-1' => 'test',
- 'X-Wf-1-1-1-2' => 'test',
- );
-
- $this->assertEquals($expected, $handler->getHeaders());
- }
-
- public function testConcurrentHandlers()
- {
- $handler = new TestFirePHPHandler;
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::WARNING));
-
- $handler2 = new TestFirePHPHandler;
- $handler2->setFormatter($this->getIdentityFormatter());
- $handler2->handle($this->getRecord(Logger::DEBUG));
- $handler2->handle($this->getRecord(Logger::WARNING));
-
- $expected = array(
- 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
- 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
- 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
- 'X-Wf-1-1-1-1' => 'test',
- 'X-Wf-1-1-1-2' => 'test',
- );
-
- $expected2 = array(
- 'X-Wf-1-1-1-3' => 'test',
- 'X-Wf-1-1-1-4' => 'test',
- );
-
- $this->assertEquals($expected, $handler->getHeaders());
- $this->assertEquals($expected2, $handler2->getHeaders());
- }
-}
-
-class TestFirePHPHandler extends FirePHPHandler
-{
- protected $headers = array();
-
- public static function reset()
- {
- self::$initialized = false;
- self::$sendHeaders = true;
- self::$messageIndex = 1;
- }
-
- protected function sendHeader($header, $content)
- {
- $this->headers[$header] = $content;
- }
-
- public function getHeaders()
- {
- return $this->headers;
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php
deleted file mode 100644
index 91cdd31..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php
+++ /dev/null
@@ -1,85 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Formatter\LineFormatter;
-use Monolog\Logger;
-use Monolog\TestCase;
-
-/**
- * @coversDefaultClass \Monolog\Handler\FleepHookHandler
- */
-class FleepHookHandlerTest extends TestCase
-{
- /**
- * Default token to use in tests
- */
- const TOKEN = '123abc';
-
- /**
- * @var FleepHookHandler
- */
- private $handler;
-
- public function setUp()
- {
- parent::setUp();
-
- if (!extension_loaded('openssl')) {
- $this->markTestSkipped('This test requires openssl extension to run');
- }
-
- // Create instances of the handler and logger for convenience
- $this->handler = new FleepHookHandler(self::TOKEN);
- }
-
- /**
- * @covers ::__construct
- */
- public function testConstructorSetsExpectedDefaults()
- {
- $this->assertEquals(Logger::DEBUG, $this->handler->getLevel());
- $this->assertEquals(true, $this->handler->getBubble());
- }
-
- /**
- * @covers ::getDefaultFormatter
- */
- public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
- {
- $record = array(
- 'message' => 'msg',
- 'context' => array(),
- 'level' => Logger::DEBUG,
- 'level_name' => Logger::getLevelName(Logger::DEBUG),
- 'channel' => 'channel',
- 'datetime' => new \DateTime(),
- 'extra' => array(),
- );
-
- $expectedFormatter = new LineFormatter(null, null, true, true);
- $expected = $expectedFormatter->format($record);
-
- $handlerFormatter = $this->handler->getFormatter();
- $actual = $handlerFormatter->format($record);
-
- $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');
- }
-
- /**
- * @covers ::__construct
- */
- public function testConnectionStringisConstructedCorrectly()
- {
- $this->assertEquals('ssl://' . FleepHookHandler::FLEEP_HOST . ':443', $this->handler->getConnectionString());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php
deleted file mode 100644
index 4b120d5..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Formatter\FlowdockFormatter;
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @author Dominik Liebler
- * @see https://www.hipchat.com/docs/api
- */
-class FlowdockHandlerTest extends TestCase
-{
- /**
- * @var resource
- */
- private $res;
-
- /**
- * @var FlowdockHandler
- */
- private $handler;
-
- public function setUp()
- {
- if (!extension_loaded('openssl')) {
- $this->markTestSkipped('This test requires openssl to run');
- }
- }
-
- public function testWriteHeader()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- /**
- * @depends testWriteHeader
- */
- public function testWriteContent($content)
- {
- $this->assertRegexp('/"source":"test_source"/', $content);
- $this->assertRegexp('/"from_address":"source@test\.com"/', $content);
- }
-
- private function createHandler($token = 'myToken')
- {
- $constructorArgs = array($token, Logger::DEBUG);
- $this->res = fopen('php://memory', 'a');
- $this->handler = $this->getMock(
- '\Monolog\Handler\FlowdockHandler',
- array('fsockopen', 'streamSetTimeout', 'closeSocket'),
- $constructorArgs
- );
-
- $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->handler, 'localhost:1234');
-
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- $this->handler->expects($this->any())
- ->method('closeSocket')
- ->will($this->returnValue(true));
-
- $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php
deleted file mode 100644
index 9d007b1..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Gelf\Message;
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\GelfMessageFormatter;
-
-class GelfHandlerLegacyTest extends TestCase
-{
- public function setUp()
- {
- if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
- $this->markTestSkipped("mlehner/gelf-php not installed");
- }
-
- require_once __DIR__ . '/GelfMockMessagePublisher.php';
- }
-
- /**
- * @covers Monolog\Handler\GelfHandler::__construct
- */
- public function testConstruct()
- {
- $handler = new GelfHandler($this->getMessagePublisher());
- $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
- }
-
- protected function getHandler($messagePublisher)
- {
- $handler = new GelfHandler($messagePublisher);
-
- return $handler;
- }
-
- protected function getMessagePublisher()
- {
- return new GelfMockMessagePublisher('localhost');
- }
-
- public function testDebug()
- {
- $messagePublisher = $this->getMessagePublisher();
- $handler = $this->getHandler($messagePublisher);
-
- $record = $this->getRecord(Logger::DEBUG, "A test debug message");
- $handler->handle($record);
-
- $this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
- $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
- $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
- $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
- }
-
- public function testWarning()
- {
- $messagePublisher = $this->getMessagePublisher();
- $handler = $this->getHandler($messagePublisher);
-
- $record = $this->getRecord(Logger::WARNING, "A test warning message");
- $handler->handle($record);
-
- $this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
- $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
- $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
- $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
- }
-
- public function testInjectedGelfMessageFormatter()
- {
- $messagePublisher = $this->getMessagePublisher();
- $handler = $this->getHandler($messagePublisher);
-
- $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
-
- $record = $this->getRecord(Logger::WARNING, "A test warning message");
- $record['extra']['blarg'] = 'yep';
- $record['context']['from'] = 'logger';
- $handler->handle($record);
-
- $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
- $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
- $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
deleted file mode 100644
index 8cdd64f..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
+++ /dev/null
@@ -1,117 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Gelf\Message;
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\GelfMessageFormatter;
-
-class GelfHandlerTest extends TestCase
-{
- public function setUp()
- {
- if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) {
- $this->markTestSkipped("graylog2/gelf-php not installed");
- }
- }
-
- /**
- * @covers Monolog\Handler\GelfHandler::__construct
- */
- public function testConstruct()
- {
- $handler = new GelfHandler($this->getMessagePublisher());
- $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
- }
-
- protected function getHandler($messagePublisher)
- {
- $handler = new GelfHandler($messagePublisher);
-
- return $handler;
- }
-
- protected function getMessagePublisher()
- {
- return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false);
- }
-
- public function testDebug()
- {
- $record = $this->getRecord(Logger::DEBUG, "A test debug message");
- $expectedMessage = new Message();
- $expectedMessage
- ->setLevel(7)
- ->setFacility("test")
- ->setShortMessage($record['message'])
- ->setTimestamp($record['datetime'])
- ;
-
- $messagePublisher = $this->getMessagePublisher();
- $messagePublisher->expects($this->once())
- ->method('publish')
- ->with($expectedMessage);
-
- $handler = $this->getHandler($messagePublisher);
-
- $handler->handle($record);
- }
-
- public function testWarning()
- {
- $record = $this->getRecord(Logger::WARNING, "A test warning message");
- $expectedMessage = new Message();
- $expectedMessage
- ->setLevel(4)
- ->setFacility("test")
- ->setShortMessage($record['message'])
- ->setTimestamp($record['datetime'])
- ;
-
- $messagePublisher = $this->getMessagePublisher();
- $messagePublisher->expects($this->once())
- ->method('publish')
- ->with($expectedMessage);
-
- $handler = $this->getHandler($messagePublisher);
-
- $handler->handle($record);
- }
-
- public function testInjectedGelfMessageFormatter()
- {
- $record = $this->getRecord(Logger::WARNING, "A test warning message");
- $record['extra']['blarg'] = 'yep';
- $record['context']['from'] = 'logger';
-
- $expectedMessage = new Message();
- $expectedMessage
- ->setLevel(4)
- ->setFacility("test")
- ->setHost("mysystem")
- ->setShortMessage($record['message'])
- ->setTimestamp($record['datetime'])
- ->setAdditional("EXTblarg", 'yep')
- ->setAdditional("CTXfrom", 'logger')
- ;
-
- $messagePublisher = $this->getMessagePublisher();
- $messagePublisher->expects($this->once())
- ->method('publish')
- ->with($expectedMessage);
-
- $handler = $this->getHandler($messagePublisher);
- $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
- $handler->handle($record);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php
deleted file mode 100644
index 873d92f..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php
+++ /dev/null
@@ -1,25 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Gelf\MessagePublisher;
-use Gelf\Message;
-
-class GelfMockMessagePublisher extends MessagePublisher
-{
- public function publish(Message $message)
- {
- $this->lastMessage = $message;
- }
-
- public $lastMessage = null;
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
deleted file mode 100644
index c6298a6..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class GroupHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\GroupHandler::__construct
- * @expectedException InvalidArgumentException
- */
- public function testConstructorOnlyTakesHandler()
- {
- new GroupHandler(array(new TestHandler(), "foo"));
- }
-
- /**
- * @covers Monolog\Handler\GroupHandler::__construct
- * @covers Monolog\Handler\GroupHandler::handle
- */
- public function testHandle()
- {
- $testHandlers = array(new TestHandler(), new TestHandler());
- $handler = new GroupHandler($testHandlers);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- foreach ($testHandlers as $test) {
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 2);
- }
- }
-
- /**
- * @covers Monolog\Handler\GroupHandler::handleBatch
- */
- public function testHandleBatch()
- {
- $testHandlers = array(new TestHandler(), new TestHandler());
- $handler = new GroupHandler($testHandlers);
- $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
- foreach ($testHandlers as $test) {
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 2);
- }
- }
-
- /**
- * @covers Monolog\Handler\GroupHandler::isHandling
- */
- public function testIsHandling()
- {
- $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
- $handler = new GroupHandler($testHandlers);
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\GroupHandler::handle
- */
- public function testHandleUsesProcessors()
- {
- $test = new TestHandler();
- $handler = new GroupHandler(array($test));
- $handler->pushProcessor(function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php
deleted file mode 100644
index 462dac8..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php
+++ /dev/null
@@ -1,244 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @author Rafael Dohms
- * @see https://www.hipchat.com/docs/api
- */
-class HipChatHandlerTest extends TestCase
-{
- private $res;
- private $handler;
-
- public function testWriteHeader()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- public function testWriteCustomHostHeader()
- {
- $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar');
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- public function testWriteV2()
- {
- $this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2');
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- public function testWriteV2Notify()
- {
- $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2');
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- public function testRoomSpaces()
- {
- $this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2');
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/v2\/room\/room%20name\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- /**
- * @depends testWriteHeader
- */
- public function testWriteContent($content)
- {
- $this->assertRegexp('/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
- }
-
- /**
- * @depends testWriteCustomHostHeader
- */
- public function testWriteContentNotify($content)
- {
- $this->assertRegexp('/notify=1&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
- }
-
- /**
- * @depends testWriteV2
- */
- public function testWriteContentV2($content)
- {
- $this->assertRegexp('/notify=false&message=test1&message_format=text&color=red$/', $content);
- }
-
- /**
- * @depends testWriteV2Notify
- */
- public function testWriteContentV2Notify($content)
- {
- $this->assertRegexp('/notify=true&message=test1&message_format=text&color=red$/', $content);
- }
-
- public function testWriteWithComplexMessage()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
- }
-
- /**
- * @dataProvider provideLevelColors
- */
- public function testWriteWithErrorLevelsAndColors($level, $expectedColor)
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord($level, 'Backup of database "example" finished in 16 minutes.'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/color='.$expectedColor.'/', $content);
- }
-
- public function provideLevelColors()
- {
- return array(
- array(Logger::DEBUG, 'gray'),
- array(Logger::INFO, 'green'),
- array(Logger::WARNING, 'yellow'),
- array(Logger::ERROR, 'red'),
- array(Logger::CRITICAL, 'red'),
- array(Logger::ALERT, 'red'),
- array(Logger::EMERGENCY,'red'),
- array(Logger::NOTICE, 'green'),
- );
- }
-
- /**
- * @dataProvider provideBatchRecords
- */
- public function testHandleBatch($records, $expectedColor)
- {
- $this->createHandler();
-
- $this->handler->handleBatch($records);
-
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/color='.$expectedColor.'/', $content);
- }
-
- public function provideBatchRecords()
- {
- return array(
- array(
- array(
- array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
- array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
- array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime())
- ),
- 'red',
- ),
- array(
- array(
- array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
- array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
- ),
- 'yellow',
- ),
- array(
- array(
- array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
- array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
- ),
- 'green',
- ),
- array(
- array(
- array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
- ),
- 'gray',
- ),
- );
- }
-
- private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com', $version = 'v1')
- {
- $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version);
- $this->res = fopen('php://memory', 'a');
- $this->handler = $this->getMock(
- '\Monolog\Handler\HipChatHandler',
- array('fsockopen', 'streamSetTimeout', 'closeSocket'),
- $constructorArgs
- );
-
- $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->handler, 'localhost:1234');
-
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- $this->handler->expects($this->any())
- ->method('closeSocket')
- ->will($this->returnValue(true));
-
- $this->handler->setFormatter($this->getIdentityFormatter());
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- public function testCreateWithTooLongName()
- {
- $hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere');
- }
-
- public function testCreateWithTooLongNameV2()
- {
- // creating a handler with too long of a name but using the v2 api doesn't matter.
- $hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php
deleted file mode 100644
index 7af60be..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @author Robert Kaufmann III
- */
-class LogEntriesHandlerTest extends TestCase
-{
- /**
- * @var resource
- */
- private $res;
-
- /**
- * @var LogEntriesHandler
- */
- private $handler;
-
- public function testWriteContent()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
-
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
- }
-
- public function testWriteBatchContent()
- {
- $records = array(
- $this->getRecord(),
- $this->getRecord(),
- $this->getRecord()
- );
- $this->createHandler();
- $this->handler->handleBatch($records);
-
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
- }
-
- private function createHandler()
- {
- $useSSL = extension_loaded('openssl');
- $args = array('testToken', $useSSL, Logger::DEBUG, true);
- $this->res = fopen('php://memory', 'a');
- $this->handler = $this->getMock(
- '\Monolog\Handler\LogEntriesHandler',
- array('fsockopen', 'streamSetTimeout', 'closeSocket'),
- $args
- );
-
- $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->handler, 'localhost:1234');
-
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- $this->handler->expects($this->any())
- ->method('closeSocket')
- ->will($this->returnValue(true));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
deleted file mode 100644
index 6754f3d..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
+++ /dev/null
@@ -1,75 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Logger;
-use Monolog\TestCase;
-
-class MailHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\MailHandler::handleBatch
- */
- public function testHandleBatch()
- {
- $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
- $formatter->expects($this->once())
- ->method('formatBatch'); // Each record is formatted
-
- $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
- $handler->expects($this->once())
- ->method('send');
- $handler->expects($this->never())
- ->method('write'); // write is for individual records
-
- $handler->setFormatter($formatter);
-
- $handler->handleBatch($this->getMultipleRecords());
- }
-
- /**
- * @covers Monolog\Handler\MailHandler::handleBatch
- */
- public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
- {
- $records = array(
- $this->getRecord(Logger::DEBUG, 'debug message 1'),
- $this->getRecord(Logger::DEBUG, 'debug message 2'),
- $this->getRecord(Logger::INFO, 'information'),
- );
-
- $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
- $handler->expects($this->never())
- ->method('send');
- $handler->setLevel(Logger::ERROR);
-
- $handler->handleBatch($records);
- }
-
- /**
- * @covers Monolog\Handler\MailHandler::write
- */
- public function testHandle()
- {
- $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
-
- $record = $this->getRecord();
- $records = array($record);
- $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n";
-
- $handler->expects($this->once())
- ->method('send')
- ->with($records[0]['formatted'], $records);
-
- $handler->handle($record);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
deleted file mode 100644
index a083322..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Raven_Client;
-
-class MockRavenClient extends Raven_Client
-{
- public function capture($data, $stack, $vars = null)
- {
- $data = array_merge($this->get_user_data(), $data);
- $this->lastData = $data;
- $this->lastStack = $stack;
- }
-
- public $lastData;
- public $lastStack;
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
deleted file mode 100644
index 0fdef63..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class MongoDBHandlerTest extends TestCase
-{
- /**
- * @expectedException InvalidArgumentException
- */
- public function testConstructorShouldThrowExceptionForInvalidMongo()
- {
- new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
- }
-
- public function testHandle()
- {
- $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
- $collection = $this->getMock('stdClass', array('save'));
-
- $mongo->expects($this->once())
- ->method('selectCollection')
- ->with('DB', 'Collection')
- ->will($this->returnValue($collection));
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $expected = array(
- 'message' => 'test',
- 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
- 'level' => Logger::WARNING,
- 'level_name' => 'WARNING',
- 'channel' => 'test',
- 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
- 'extra' => array(),
- );
-
- $collection->expects($this->once())
- ->method('save')
- ->with($expected);
-
- $handler = new MongoDBHandler($mongo, 'DB', 'Collection');
- $handler->handle($record);
- }
-}
-
-if (!class_exists('Mongo')) {
- class Mongo
- {
- public function selectCollection()
- {
- }
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
deleted file mode 100644
index c2553ee..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-
-class NativeMailerHandlerTest extends TestCase
-{
- /**
- * @expectedException InvalidArgumentException
- */
- public function testConstructorHeaderInjection()
- {
- $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- public function testSetterHeaderInjection()
- {
- $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
- $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- public function testSetterArrayHeaderInjection()
- {
- $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
- $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- public function testSetterContentTypeInjection()
- {
- $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
- $mailer->setContentType("text/html\r\nFrom: faked@attacker.org");
- }
-
- /**
- * @expectedException InvalidArgumentException
- */
- public function testSetterEncodingInjection()
- {
- $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
- $mailer->setEncoding("utf-8\r\nFrom: faked@attacker.org");
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php
deleted file mode 100644
index 4eda615..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php
+++ /dev/null
@@ -1,192 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class NewRelicHandlerTest extends TestCase
-{
- public static $appname;
- public static $customParameters;
- public static $transactionName;
-
- public function setUp()
- {
- self::$appname = null;
- self::$customParameters = array();
- self::$transactionName = null;
- }
-
- /**
- * @expectedException Monolog\Handler\MissingExtensionException
- */
- public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded()
- {
- $handler = new StubNewRelicHandlerWithoutExtension();
- $handler->handle($this->getRecord(Logger::ERROR));
- }
-
- public function testThehandlerCanHandleTheRecord()
- {
- $handler = new StubNewRelicHandler();
- $handler->handle($this->getRecord(Logger::ERROR));
- }
-
- public function testThehandlerCanAddContextParamsToTheNewRelicTrace()
- {
- $handler = new StubNewRelicHandler();
- $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
- $this->assertEquals(array('context_a' => 'b'), self::$customParameters);
- }
-
- public function testThehandlerCanAddExplodedContextParamsToTheNewRelicTrace()
- {
- $handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
- $handler->handle($this->getRecord(
- Logger::ERROR,
- 'log message',
- array('a' => array('key1' => 'value1', 'key2' => 'value2'))
- ));
- $this->assertEquals(
- array('context_a_key1' => 'value1', 'context_a_key2' => 'value2'),
- self::$customParameters
- );
- }
-
- public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
- {
- $record = $this->getRecord(Logger::ERROR, 'log message');
- $record['extra'] = array('c' => 'd');
-
- $handler = new StubNewRelicHandler();
- $handler->handle($record);
-
- $this->assertEquals(array('extra_c' => 'd'), self::$customParameters);
- }
-
- public function testThehandlerCanAddExplodedExtraParamsToTheNewRelicTrace()
- {
- $record = $this->getRecord(Logger::ERROR, 'log message');
- $record['extra'] = array('c' => array('key1' => 'value1', 'key2' => 'value2'));
-
- $handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
- $handler->handle($record);
-
- $this->assertEquals(
- array('extra_c_key1' => 'value1', 'extra_c_key2' => 'value2'),
- self::$customParameters
- );
- }
-
- public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
- {
- $record = $this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'));
- $record['extra'] = array('c' => 'd');
-
- $handler = new StubNewRelicHandler();
- $handler->handle($record);
-
- $expected = array(
- 'context_a' => 'b',
- 'extra_c' => 'd',
- );
-
- $this->assertEquals($expected, self::$customParameters);
- }
-
- public function testTheAppNameIsNullByDefault()
- {
- $handler = new StubNewRelicHandler();
- $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
-
- $this->assertEquals(null, self::$appname);
- }
-
- public function testTheAppNameCanBeInjectedFromtheConstructor()
- {
- $handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName');
- $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
-
- $this->assertEquals('myAppName', self::$appname);
- }
-
- public function testTheAppNameCanBeOverriddenFromEachLog()
- {
- $handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName');
- $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName')));
-
- $this->assertEquals('logAppName', self::$appname);
- }
-
- public function testTheTransactionNameIsNullByDefault()
- {
- $handler = new StubNewRelicHandler();
- $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
-
- $this->assertEquals(null, self::$transactionName);
- }
-
- public function testTheTransactionNameCanBeInjectedFromTheConstructor()
- {
- $handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction');
- $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
-
- $this->assertEquals('myTransaction', self::$transactionName);
- }
-
- public function testTheTransactionNameCanBeOverriddenFromEachLog()
- {
- $handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction');
- $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('transaction_name' => 'logTransactName')));
-
- $this->assertEquals('logTransactName', self::$transactionName);
- }
-}
-
-class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
-{
- protected function isNewRelicEnabled()
- {
- return false;
- }
-}
-
-class StubNewRelicHandler extends NewRelicHandler
-{
- protected function isNewRelicEnabled()
- {
- return true;
- }
-}
-
-function newrelic_notice_error()
-{
- return true;
-}
-
-function newrelic_set_appname($appname)
-{
- return NewRelicHandlerTest::$appname = $appname;
-}
-
-function newrelic_name_transaction($transactionName)
-{
- return NewRelicHandlerTest::$transactionName = $transactionName;
-}
-
-function newrelic_add_custom_parameter($key, $value)
-{
- NewRelicHandlerTest::$customParameters[$key] = $value;
-
- return true;
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
deleted file mode 100644
index 292df78..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\NullHandler::handle
- */
-class NullHandlerTest extends TestCase
-{
- public function testHandle()
- {
- $handler = new NullHandler();
- $this->assertTrue($handler->handle($this->getRecord()));
- }
-
- public function testHandleLowerLevelRecord()
- {
- $handler = new NullHandler(Logger::WARNING);
- $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php
deleted file mode 100644
index ee95172..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php
+++ /dev/null
@@ -1,274 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Exception;
-use Monolog\ErrorHandler;
-use Monolog\Logger;
-use Monolog\TestCase;
-use PhpConsole\Connector;
-use PhpConsole\Dispatcher\Debug as DebugDispatcher;
-use PhpConsole\Dispatcher\Errors as ErrorDispatcher;
-use PhpConsole\Handler;
-use PHPUnit_Framework_MockObject_MockObject;
-
-/**
- * @covers Monolog\Handler\PHPConsoleHandler
- * @author Sergey Barbushin https://www.linkedin.com/in/barbushin
- */
-class PHPConsoleHandlerTest extends TestCase
-{
-
- /** @var Connector|PHPUnit_Framework_MockObject_MockObject */
- protected $connector;
- /** @var DebugDispatcher|PHPUnit_Framework_MockObject_MockObject */
- protected $debugDispatcher;
- /** @var ErrorDispatcher|PHPUnit_Framework_MockObject_MockObject */
- protected $errorDispatcher;
-
- protected function setUp()
- {
- if (!class_exists('PhpConsole\Connector')) {
- $this->markTestSkipped('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
- }
- $this->connector = $this->initConnectorMock();
-
- $this->debugDispatcher = $this->initDebugDispatcherMock($this->connector);
- $this->connector->setDebugDispatcher($this->debugDispatcher);
-
- $this->errorDispatcher = $this->initErrorDispatcherMock($this->connector);
- $this->connector->setErrorsDispatcher($this->errorDispatcher);
- }
-
- protected function initDebugDispatcherMock(Connector $connector)
- {
- return $this->getMockBuilder('PhpConsole\Dispatcher\Debug')
- ->disableOriginalConstructor()
- ->setMethods(array('dispatchDebug'))
- ->setConstructorArgs(array($connector, $connector->getDumper()))
- ->getMock();
- }
-
- protected function initErrorDispatcherMock(Connector $connector)
- {
- return $this->getMockBuilder('PhpConsole\Dispatcher\Errors')
- ->disableOriginalConstructor()
- ->setMethods(array('dispatchError', 'dispatchException'))
- ->setConstructorArgs(array($connector, $connector->getDumper()))
- ->getMock();
- }
-
- protected function initConnectorMock()
- {
- $connector = $this->getMockBuilder('PhpConsole\Connector')
- ->disableOriginalConstructor()
- ->setMethods(array(
- 'sendMessage',
- 'onShutDown',
- 'isActiveClient',
- 'setSourcesBasePath',
- 'setServerEncoding',
- 'setPassword',
- 'enableSslOnlyMode',
- 'setAllowedIpMasks',
- 'setHeadersLimit',
- 'startEvalRequestsListener',
- ))
- ->getMock();
-
- $connector->expects($this->any())
- ->method('isActiveClient')
- ->will($this->returnValue(true));
-
- return $connector;
- }
-
- protected function getHandlerDefaultOption($name)
- {
- $handler = new PHPConsoleHandler(array(), $this->connector);
- $options = $handler->getOptions();
-
- return $options[$name];
- }
-
- protected function initLogger($handlerOptions = array(), $level = Logger::DEBUG)
- {
- return new Logger('test', array(
- new PHPConsoleHandler($handlerOptions, $this->connector, $level)
- ));
- }
-
- public function testInitWithDefaultConnector()
- {
- $handler = new PHPConsoleHandler();
- $this->assertEquals(spl_object_hash(Connector::getInstance()), spl_object_hash($handler->getConnector()));
- }
-
- public function testInitWithCustomConnector()
- {
- $handler = new PHPConsoleHandler(array(), $this->connector);
- $this->assertEquals(spl_object_hash($this->connector), spl_object_hash($handler->getConnector()));
- }
-
- public function testDebug()
- {
- $this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with($this->equalTo('test'));
- $this->initLogger()->addDebug('test');
- }
-
- public function testDebugContextInMessage()
- {
- $message = 'test';
- $tag = 'tag';
- $context = array($tag, 'custom' => mt_rand());
- $expectedMessage = $message . ' ' . json_encode(array_slice($context, 1));
- $this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with(
- $this->equalTo($expectedMessage),
- $this->equalTo($tag)
- );
- $this->initLogger()->addDebug($message, $context);
- }
-
- public function testDebugTags($tagsContextKeys = null)
- {
- $expectedTags = mt_rand();
- $logger = $this->initLogger($tagsContextKeys ? array('debugTagsKeysInContext' => $tagsContextKeys) : array());
- if (!$tagsContextKeys) {
- $tagsContextKeys = $this->getHandlerDefaultOption('debugTagsKeysInContext');
- }
- foreach ($tagsContextKeys as $key) {
- $debugDispatcher = $this->initDebugDispatcherMock($this->connector);
- $debugDispatcher->expects($this->once())->method('dispatchDebug')->with(
- $this->anything(),
- $this->equalTo($expectedTags)
- );
- $this->connector->setDebugDispatcher($debugDispatcher);
- $logger->addDebug('test', array($key => $expectedTags));
- }
- }
-
- public function testError($classesPartialsTraceIgnore = null)
- {
- $code = E_USER_NOTICE;
- $message = 'message';
- $file = __FILE__;
- $line = __LINE__;
- $this->errorDispatcher->expects($this->once())->method('dispatchError')->with(
- $this->equalTo($code),
- $this->equalTo($message),
- $this->equalTo($file),
- $this->equalTo($line),
- $classesPartialsTraceIgnore ?: $this->equalTo($this->getHandlerDefaultOption('classesPartialsTraceIgnore'))
- );
- $errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? array('classesPartialsTraceIgnore' => $classesPartialsTraceIgnore) : array()), false);
- $errorHandler->registerErrorHandler(array(), false, E_USER_WARNING);
- $errorHandler->handleError($code, $message, $file, $line);
- }
-
- public function testException()
- {
- $e = new Exception();
- $this->errorDispatcher->expects($this->once())->method('dispatchException')->with(
- $this->equalTo($e)
- );
- $handler = $this->initLogger();
- $handler->log(
- \Psr\Log\LogLevel::ERROR,
- sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
- array('exception' => $e)
- );
- }
-
- /**
- * @expectedException Exception
- */
- public function testWrongOptionsThrowsException()
- {
- new PHPConsoleHandler(array('xxx' => 1));
- }
-
- public function testOptionEnabled()
- {
- $this->debugDispatcher->expects($this->never())->method('dispatchDebug');
- $this->initLogger(array('enabled' => false))->addDebug('test');
- }
-
- public function testOptionClassesPartialsTraceIgnore()
- {
- $this->testError(array('Class', 'Namespace\\'));
- }
-
- public function testOptionDebugTagsKeysInContext()
- {
- $this->testDebugTags(array('key1', 'key2'));
- }
-
- public function testOptionUseOwnErrorsAndExceptionsHandler()
- {
- $this->initLogger(array('useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true));
- $this->assertEquals(array(Handler::getInstance(), 'handleError'), set_error_handler(function () {
- }));
- $this->assertEquals(array(Handler::getInstance(), 'handleException'), set_exception_handler(function () {
- }));
- }
-
- public static function provideConnectorMethodsOptionsSets()
- {
- return array(
- array('sourcesBasePath', 'setSourcesBasePath', __DIR__),
- array('serverEncoding', 'setServerEncoding', 'cp1251'),
- array('password', 'setPassword', '******'),
- array('enableSslOnlyMode', 'enableSslOnlyMode', true, false),
- array('ipMasks', 'setAllowedIpMasks', array('127.0.0.*')),
- array('headersLimit', 'setHeadersLimit', 2500),
- array('enableEvalListener', 'startEvalRequestsListener', true, false),
- );
- }
-
- /**
- * @dataProvider provideConnectorMethodsOptionsSets
- */
- public function testOptionCallsConnectorMethod($option, $method, $value, $isArgument = true)
- {
- $expectCall = $this->connector->expects($this->once())->method($method);
- if ($isArgument) {
- $expectCall->with($value);
- }
- new PHPConsoleHandler(array($option => $value), $this->connector);
- }
-
- public function testOptionDetectDumpTraceAndSource()
- {
- new PHPConsoleHandler(array('detectDumpTraceAndSource' => true), $this->connector);
- $this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource);
- }
-
- public static function provideDumperOptionsValues()
- {
- return array(
- array('dumperLevelLimit', 'levelLimit', 1001),
- array('dumperItemsCountLimit', 'itemsCountLimit', 1002),
- array('dumperItemSizeLimit', 'itemSizeLimit', 1003),
- array('dumperDumpSizeLimit', 'dumpSizeLimit', 1004),
- array('dumperDetectCallbacks', 'detectCallbacks', true),
- );
- }
-
- /**
- * @dataProvider provideDumperOptionsValues
- */
- public function testDumperOptions($option, $dumperProperty, $value)
- {
- new PHPConsoleHandler(array($option => $value), $this->connector);
- $this->assertEquals($value, $this->connector->getDumper()->$dumperProperty);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php
deleted file mode 100644
index 64eaab1..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\PsrHandler::handle
- */
-class PsrHandlerTest extends TestCase
-{
- public function logLevelProvider()
- {
- $levels = array();
- $monologLogger = new Logger('');
-
- foreach ($monologLogger->getLevels() as $levelName => $level) {
- $levels[] = array($levelName, $level);
- }
-
- return $levels;
- }
-
- /**
- * @dataProvider logLevelProvider
- */
- public function testHandlesAllLevels($levelName, $level)
- {
- $message = 'Hello, world! ' . $level;
- $context = array('foo' => 'bar', 'level' => $level);
-
- $psrLogger = $this->getMock('Psr\Log\NullLogger');
- $psrLogger->expects($this->once())
- ->method('log')
- ->with(strtolower($levelName), $message, $context);
-
- $handler = new PsrHandler($psrLogger);
- $handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
deleted file mode 100644
index 8940823..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * Almost all examples (expected header, titles, messages) taken from
- * https://www.pushover.net/api
- * @author Sebastian Göttschkes
- * @see https://www.pushover.net/api
- */
-class PushoverHandlerTest extends TestCase
-{
- private $res;
- private $handler;
-
- public function testWriteHeader()
- {
- $this->createHandler();
- $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
-
- return $content;
- }
-
- /**
- * @depends testWriteHeader
- */
- public function testWriteContent($content)
- {
- $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content);
- }
-
- public function testWriteWithComplexTitle()
- {
- $this->createHandler('myToken', 'myUser', 'Backup finished - SQL1', Logger::EMERGENCY);
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content);
- }
-
- public function testWriteWithComplexMessage()
- {
- $this->createHandler();
- $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
- }
-
- public function testWriteWithTooLongMessage()
- {
- $message = str_pad('test', 520, 'a');
- $this->createHandler();
- $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
- $this->handler->handle($this->getRecord(Logger::CRITICAL, $message));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $expectedMessage = substr($message, 0, 505);
-
- $this->assertRegexp('/message=' . $expectedMessage . '&title/', $content);
- }
-
- public function testWriteWithHighPriority()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content);
- }
-
- public function testWriteWithEmergencyPriority()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
- }
-
- public function testWriteToMultipleUsers()
- {
- $this->createHandler('myToken', array('userA', 'userB'));
- $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/token=myToken&user=userA&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200POST/', $content);
- $this->assertRegexp('/token=myToken&user=userB&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
- }
-
- private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
- {
- $constructorArgs = array($token, $user, $title);
- $this->res = fopen('php://memory', 'a');
- $this->handler = $this->getMock(
- '\Monolog\Handler\PushoverHandler',
- array('fsockopen', 'streamSetTimeout', 'closeSocket'),
- $constructorArgs
- );
-
- $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->handler, 'localhost:1234');
-
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- $this->handler->expects($this->any())
- ->method('closeSocket')
- ->will($this->returnValue(true));
-
- $this->handler->setFormatter($this->getIdentityFormatter());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
deleted file mode 100644
index 2ca5c02..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
+++ /dev/null
@@ -1,199 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\LineFormatter;
-
-class RavenHandlerTest extends TestCase
-{
- public function setUp()
- {
- if (!class_exists('Raven_Client')) {
- $this->markTestSkipped('raven/raven not installed');
- }
-
- require_once __DIR__ . '/MockRavenClient.php';
- }
-
- /**
- * @covers Monolog\Handler\RavenHandler::__construct
- */
- public function testConstruct()
- {
- $handler = new RavenHandler($this->getRavenClient());
- $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler);
- }
-
- protected function getHandler($ravenClient)
- {
- $handler = new RavenHandler($ravenClient);
-
- return $handler;
- }
-
- protected function getRavenClient()
- {
- $dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
-
- return new MockRavenClient($dsn);
- }
-
- public function testDebug()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $record = $this->getRecord(Logger::DEBUG, 'A test debug message');
- $handler->handle($record);
-
- $this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
- $this->assertContains($record['message'], $ravenClient->lastData['message']);
- }
-
- public function testWarning()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $record = $this->getRecord(Logger::WARNING, 'A test warning message');
- $handler->handle($record);
-
- $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
- $this->assertContains($record['message'], $ravenClient->lastData['message']);
- }
-
- public function testTag()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $tags = array(1, 2, 'foo');
- $record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags));
- $handler->handle($record);
-
- $this->assertEquals($tags, $ravenClient->lastData['tags']);
- }
-
- public function testExtraParameters()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $checksum = '098f6bcd4621d373cade4e832627b4f6';
- $release = '05a671c66aefea124cc08b76ea6d30bb';
- $record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum, 'release' => $release));
- $handler->handle($record);
-
- $this->assertEquals($checksum, $ravenClient->lastData['checksum']);
- $this->assertEquals($release, $ravenClient->lastData['release']);
- }
-
- public function testUserContext()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
- // set user context 'externally'
-
- $user = array(
- 'id' => '123',
- 'email' => 'test@test.com'
- );
-
- $recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
-
- $ravenClient->user_context(array('id' => 'test_user_id'));
- // handle context
- $handler->handle($recordWithContext);
- $this->assertEquals($user, $ravenClient->lastData['user']);
-
- // check to see if its reset
- $handler->handle($recordWithNoContext);
- $this->assertInternalType('array', $ravenClient->context->user);
- $this->assertSame('test_user_id', $ravenClient->context->user['id']);
-
- // handle with null context
- $ravenClient->user_context(null);
- $handler->handle($recordWithContext);
- $this->assertEquals($user, $ravenClient->lastData['user']);
-
- // check to see if its reset
- $handler->handle($recordWithNoContext);
- $this->assertNull($ravenClient->context->user);
- }
-
- public function testException()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- try {
- $this->methodThatThrowsAnException();
- } catch (\Exception $e) {
- $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
- $handler->handle($record);
- }
-
- $this->assertEquals($record['message'], $ravenClient->lastData['message']);
- }
-
- public function testHandleBatch()
- {
- $records = $this->getMultipleRecords();
- $records[] = $this->getRecord(Logger::WARNING, 'warning');
- $records[] = $this->getRecord(Logger::WARNING, 'warning');
-
- $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
- $logFormatter->expects($this->once())->method('formatBatch');
-
- $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
- $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
- return $record['level'] == 400;
- }));
-
- $handler = $this->getHandler($this->getRavenClient());
- $handler->setBatchFormatter($logFormatter);
- $handler->setFormatter($formatter);
- $handler->handleBatch($records);
- }
-
- public function testHandleBatchDoNothingIfRecordsAreBelowLevel()
- {
- $records = array(
- $this->getRecord(Logger::DEBUG, 'debug message 1'),
- $this->getRecord(Logger::DEBUG, 'debug message 2'),
- $this->getRecord(Logger::INFO, 'information'),
- );
-
- $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
- $handler->expects($this->never())->method('handle');
- $handler->setLevel(Logger::ERROR);
- $handler->handleBatch($records);
- }
-
- public function testGetSetBatchFormatter()
- {
- $ravenClient = $this->getRavenClient();
- $handler = $this->getHandler($ravenClient);
-
- $handler->setBatchFormatter($formatter = new LineFormatter());
- $this->assertSame($formatter, $handler->getBatchFormatter());
- }
-
- private function methodThatThrowsAnException()
- {
- throw new \Exception('This is an exception');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
deleted file mode 100644
index 97e0d94..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
+++ /dev/null
@@ -1,127 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-use Monolog\Formatter\LineFormatter;
-
-class RedisHandlerTest extends TestCase
-{
- /**
- * @expectedException InvalidArgumentException
- */
- public function testConstructorShouldThrowExceptionForInvalidRedis()
- {
- new RedisHandler(new \stdClass(), 'key');
- }
-
- public function testConstructorShouldWorkWithPredis()
- {
- $redis = $this->getMock('Predis\Client');
- $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
- }
-
- public function testConstructorShouldWorkWithRedis()
- {
- $redis = $this->getMock('Redis');
- $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
- }
-
- public function testPredisHandle()
- {
- $redis = $this->getMock('Predis\Client', array('rpush'));
-
- // Predis\Client uses rpush
- $redis->expects($this->once())
- ->method('rpush')
- ->with('key', 'test');
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $handler = new RedisHandler($redis, 'key');
- $handler->setFormatter(new LineFormatter("%message%"));
- $handler->handle($record);
- }
-
- public function testRedisHandle()
- {
- $redis = $this->getMock('Redis', array('rpush'));
-
- // Redis uses rPush
- $redis->expects($this->once())
- ->method('rPush')
- ->with('key', 'test');
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $handler = new RedisHandler($redis, 'key');
- $handler->setFormatter(new LineFormatter("%message%"));
- $handler->handle($record);
- }
-
- public function testRedisHandleCapped()
- {
- $redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'execute'));
-
- // Redis uses multi
- $redis->expects($this->once())
- ->method('multi')
- ->will($this->returnSelf());
-
- $redis->expects($this->once())
- ->method('rpush')
- ->will($this->returnSelf());
-
- $redis->expects($this->once())
- ->method('ltrim')
- ->will($this->returnSelf());
-
- $redis->expects($this->once())
- ->method('execute')
- ->will($this->returnSelf());
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
- $handler->setFormatter(new LineFormatter("%message%"));
- $handler->handle($record);
- }
-
- public function testPredisHandleCapped()
- {
- $redis = $this->getMock('Predis\Client', array('transaction'));
-
- $redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim'));
-
- $redisTransaction->expects($this->once())
- ->method('rpush')
- ->will($this->returnSelf());
-
- $redisTransaction->expects($this->once())
- ->method('ltrim')
- ->will($this->returnSelf());
-
- // Redis uses multi
- $redis->expects($this->once())
- ->method('transaction')
- ->will($this->returnCallback(function ($cb) use ($redisTransaction) {
- $cb($redisTransaction);
- }));
-
- $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
-
- $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
- $handler->setFormatter(new LineFormatter("%message%"));
- $handler->handle($record);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
deleted file mode 100644
index f4cefda..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-
-/**
- * @covers Monolog\Handler\RotatingFileHandler
- */
-class RotatingFileHandlerTest extends TestCase
-{
- public function setUp()
- {
- $dir = __DIR__.'/Fixtures';
- chmod($dir, 0777);
- if (!is_writable($dir)) {
- $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.');
- }
- }
-
- public function testRotationCreatesNewFile()
- {
- touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
-
- $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord());
-
- $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
- $this->assertTrue(file_exists($log));
- $this->assertEquals('test', file_get_contents($log));
- }
-
- /**
- * @dataProvider rotationTests
- */
- public function testRotation($createFile)
- {
- touch($old1 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
- touch($old2 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 2).'.rot');
- touch($old3 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 3).'.rot');
- touch($old4 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 4).'.rot');
-
- $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
-
- if ($createFile) {
- touch($log);
- }
-
- $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord());
-
- $handler->close();
-
- $this->assertTrue(file_exists($log));
- $this->assertTrue(file_exists($old1));
- $this->assertEquals($createFile, file_exists($old2));
- $this->assertEquals($createFile, file_exists($old3));
- $this->assertEquals($createFile, file_exists($old4));
- $this->assertEquals('test', file_get_contents($log));
- }
-
- public function rotationTests()
- {
- return array(
- 'Rotation is triggered when the file of the current day is not present'
- => array(true),
- 'Rotation is not triggered when the file is already present'
- => array(false),
- );
- }
-
- public function testReuseCurrentFile()
- {
- $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
- file_put_contents($log, "foo");
- $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord());
- $this->assertEquals('footest', file_get_contents($log));
- }
-
- public function tearDown()
- {
- foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) {
- unlink($file);
- }
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php
deleted file mode 100644
index b354cee..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-
-/**
- * @covers Monolog\Handler\SamplingHandler::handle
- */
-class SamplingHandlerTest extends TestCase
-{
- public function testHandle()
- {
- $testHandler = new TestHandler();
- $handler = new SamplingHandler($testHandler, 2);
- for ($i = 0; $i < 10000; $i++) {
- $handler->handle($this->getRecord());
- }
- $count = count($testHandler->getRecords());
- // $count should be half of 10k, so between 4k and 6k
- $this->assertLessThan(6000, $count);
- $this->assertGreaterThan(4000, $count);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php
deleted file mode 100644
index d657fae..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php
+++ /dev/null
@@ -1,133 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @author Greg Kedzierski
- * @see https://api.slack.com/
- */
-class SlackHandlerTest extends TestCase
-{
- /**
- * @var resource
- */
- private $res;
-
- /**
- * @var SlackHandler
- */
- private $handler;
-
- public function setUp()
- {
- if (!extension_loaded('openssl')) {
- $this->markTestSkipped('This test requires openssl to run');
- }
- }
-
- public function testWriteHeader()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/POST \/api\/chat.postMessage HTTP\/1.1\\r\\nHost: slack.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
- }
-
- public function testWriteContent()
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&text=&attachments=.*$/', $content);
- }
-
- public function testWriteContentWithEmoji()
- {
- $this->createHandler('myToken', 'channel1', 'Monolog', true, 'alien');
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/icon_emoji=%3Aalien%3A$/', $content);
- }
-
- /**
- * @dataProvider provideLevelColors
- */
- public function testWriteContentWithColors($level, $expectedColor)
- {
- $this->createHandler();
- $this->handler->handle($this->getRecord($level, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/color%22%3A%22'.$expectedColor.'/', $content);
- }
-
- public function testWriteContentWithPlainTextMessage()
- {
- $this->createHandler('myToken', 'channel1', 'Monolog', false);
- $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
- fseek($this->res, 0);
- $content = fread($this->res, 1024);
-
- $this->assertRegexp('/text=test1/', $content);
- }
-
- public function provideLevelColors()
- {
- return array(
- array(Logger::DEBUG, '%23e3e4e6'), // escaped #e3e4e6
- array(Logger::INFO, 'good'),
- array(Logger::NOTICE, 'good'),
- array(Logger::WARNING, 'warning'),
- array(Logger::ERROR, 'danger'),
- array(Logger::CRITICAL, 'danger'),
- array(Logger::ALERT, 'danger'),
- array(Logger::EMERGENCY,'danger'),
- );
- }
-
- private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeExtra = false)
- {
- $constructorArgs = array($token, $channel, $username, $useAttachment, $iconEmoji, Logger::DEBUG, true, $useShortAttachment, $includeExtra);
- $this->res = fopen('php://memory', 'a');
- $this->handler = $this->getMock(
- '\Monolog\Handler\SlackHandler',
- array('fsockopen', 'streamSetTimeout', 'closeSocket'),
- $constructorArgs
- );
-
- $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->handler, 'localhost:1234');
-
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- $this->handler->expects($this->any())
- ->method('closeSocket')
- ->will($this->returnValue(true));
-
- $this->handler->setFormatter($this->getIdentityFormatter());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
deleted file mode 100644
index 2e3d504..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
+++ /dev/null
@@ -1,282 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @author Pablo de Leon Belloc
- */
-class SocketHandlerTest extends TestCase
-{
- /**
- * @var Monolog\Handler\SocketHandler
- */
- private $handler;
-
- /**
- * @var resource
- */
- private $res;
-
- /**
- * @expectedException UnexpectedValueException
- */
- public function testInvalidHostname()
- {
- $this->createHandler('garbage://here');
- $this->writeRecord('data');
- }
-
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testBadConnectionTimeout()
- {
- $this->createHandler('localhost:1234');
- $this->handler->setConnectionTimeout(-1);
- }
-
- public function testSetConnectionTimeout()
- {
- $this->createHandler('localhost:1234');
- $this->handler->setConnectionTimeout(10.1);
- $this->assertEquals(10.1, $this->handler->getConnectionTimeout());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testBadTimeout()
- {
- $this->createHandler('localhost:1234');
- $this->handler->setTimeout(-1);
- }
-
- public function testSetTimeout()
- {
- $this->createHandler('localhost:1234');
- $this->handler->setTimeout(10.25);
- $this->assertEquals(10.25, $this->handler->getTimeout());
- }
-
- public function testSetConnectionString()
- {
- $this->createHandler('tcp://localhost:9090');
- $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
- }
-
- /**
- * @expectedException UnexpectedValueException
- */
- public function testExceptionIsThrownOnFsockopenError()
- {
- $this->setMockHandler(array('fsockopen'));
- $this->handler->expects($this->once())
- ->method('fsockopen')
- ->will($this->returnValue(false));
- $this->writeRecord('Hello world');
- }
-
- /**
- * @expectedException UnexpectedValueException
- */
- public function testExceptionIsThrownOnPfsockopenError()
- {
- $this->setMockHandler(array('pfsockopen'));
- $this->handler->expects($this->once())
- ->method('pfsockopen')
- ->will($this->returnValue(false));
- $this->handler->setPersistent(true);
- $this->writeRecord('Hello world');
- }
-
- /**
- * @expectedException UnexpectedValueException
- */
- public function testExceptionIsThrownIfCannotSetTimeout()
- {
- $this->setMockHandler(array('streamSetTimeout'));
- $this->handler->expects($this->once())
- ->method('streamSetTimeout')
- ->will($this->returnValue(false));
- $this->writeRecord('Hello world');
- }
-
- /**
- * @expectedException RuntimeException
- */
- public function testWriteFailsOnIfFwriteReturnsFalse()
- {
- $this->setMockHandler(array('fwrite'));
-
- $callback = function ($arg) {
- $map = array(
- 'Hello world' => 6,
- 'world' => false,
- );
-
- return $map[$arg];
- };
-
- $this->handler->expects($this->exactly(2))
- ->method('fwrite')
- ->will($this->returnCallback($callback));
-
- $this->writeRecord('Hello world');
- }
-
- /**
- * @expectedException RuntimeException
- */
- public function testWriteFailsIfStreamTimesOut()
- {
- $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
-
- $callback = function ($arg) {
- $map = array(
- 'Hello world' => 6,
- 'world' => 5,
- );
-
- return $map[$arg];
- };
-
- $this->handler->expects($this->exactly(1))
- ->method('fwrite')
- ->will($this->returnCallback($callback));
- $this->handler->expects($this->exactly(1))
- ->method('streamGetMetadata')
- ->will($this->returnValue(array('timed_out' => true)));
-
- $this->writeRecord('Hello world');
- }
-
- /**
- * @expectedException RuntimeException
- */
- public function testWriteFailsOnIncompleteWrite()
- {
- $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
-
- $res = $this->res;
- $callback = function ($string) use ($res) {
- fclose($res);
-
- return strlen('Hello');
- };
-
- $this->handler->expects($this->exactly(1))
- ->method('fwrite')
- ->will($this->returnCallback($callback));
- $this->handler->expects($this->exactly(1))
- ->method('streamGetMetadata')
- ->will($this->returnValue(array('timed_out' => false)));
-
- $this->writeRecord('Hello world');
- }
-
- public function testWriteWithMemoryFile()
- {
- $this->setMockHandler();
- $this->writeRecord('test1');
- $this->writeRecord('test2');
- $this->writeRecord('test3');
- fseek($this->res, 0);
- $this->assertEquals('test1test2test3', fread($this->res, 1024));
- }
-
- public function testWriteWithMock()
- {
- $this->setMockHandler(array('fwrite'));
-
- $callback = function ($arg) {
- $map = array(
- 'Hello world' => 6,
- 'world' => 5,
- );
-
- return $map[$arg];
- };
-
- $this->handler->expects($this->exactly(2))
- ->method('fwrite')
- ->will($this->returnCallback($callback));
-
- $this->writeRecord('Hello world');
- }
-
- public function testClose()
- {
- $this->setMockHandler();
- $this->writeRecord('Hello world');
- $this->assertInternalType('resource', $this->res);
- $this->handler->close();
- $this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler");
- }
-
- public function testCloseDoesNotClosePersistentSocket()
- {
- $this->setMockHandler();
- $this->handler->setPersistent(true);
- $this->writeRecord('Hello world');
- $this->assertTrue(is_resource($this->res));
- $this->handler->close();
- $this->assertTrue(is_resource($this->res));
- }
-
- private function createHandler($connectionString)
- {
- $this->handler = new SocketHandler($connectionString);
- $this->handler->setFormatter($this->getIdentityFormatter());
- }
-
- private function writeRecord($string)
- {
- $this->handler->handle($this->getRecord(Logger::WARNING, $string));
- }
-
- private function setMockHandler(array $methods = array())
- {
- $this->res = fopen('php://memory', 'a');
-
- $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
- $newMethods = array_diff($methods, $defaultMethods);
-
- $finalMethods = array_merge($defaultMethods, $newMethods);
-
- $this->handler = $this->getMock(
- '\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234')
- );
-
- if (!in_array('fsockopen', $methods)) {
- $this->handler->expects($this->any())
- ->method('fsockopen')
- ->will($this->returnValue($this->res));
- }
-
- if (!in_array('pfsockopen', $methods)) {
- $this->handler->expects($this->any())
- ->method('pfsockopen')
- ->will($this->returnValue($this->res));
- }
-
- if (!in_array('streamSetTimeout', $methods)) {
- $this->handler->expects($this->any())
- ->method('streamSetTimeout')
- ->will($this->returnValue(true));
- }
-
- $this->handler->setFormatter($this->getIdentityFormatter());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
deleted file mode 100644
index b1e22fb..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
+++ /dev/null
@@ -1,168 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class StreamHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWrite()
- {
- $handle = fopen('php://memory', 'a+');
- $handler = new StreamHandler($handle);
- $handler->setFormatter($this->getIdentityFormatter());
- $handler->handle($this->getRecord(Logger::WARNING, 'test'));
- $handler->handle($this->getRecord(Logger::WARNING, 'test2'));
- $handler->handle($this->getRecord(Logger::WARNING, 'test3'));
- fseek($handle, 0);
- $this->assertEquals('testtest2test3', fread($handle, 100));
- }
-
- /**
- * @covers Monolog\Handler\StreamHandler::close
- */
- public function testClose()
- {
- $handle = fopen('php://memory', 'a+');
- $handler = new StreamHandler($handle);
- $this->assertTrue(is_resource($handle));
- $handler->close();
- $this->assertFalse(is_resource($handle));
- }
-
- /**
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteCreatesTheStreamResource()
- {
- $handler = new StreamHandler('php://memory');
- $handler->handle($this->getRecord());
- }
-
- /**
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteLocking()
- {
- $temp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'monolog_locked_log';
- $handler = new StreamHandler($temp, Logger::DEBUG, true, null, true);
- $handler->handle($this->getRecord());
- }
-
- /**
- * @expectedException LogicException
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteMissingResource()
- {
- $handler = new StreamHandler(null);
- $handler->handle($this->getRecord());
- }
-
- public function invalidArgumentProvider()
- {
- return array(
- array(1),
- array(array()),
- array(array('bogus://url')),
- );
- }
-
- /**
- * @dataProvider invalidArgumentProvider
- * @expectedException InvalidArgumentException
- * @covers Monolog\Handler\StreamHandler::__construct
- */
- public function testWriteInvalidArgument($invalidArgument)
- {
- $handler = new StreamHandler($invalidArgument);
- }
-
- /**
- * @expectedException UnexpectedValueException
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteInvalidResource()
- {
- $handler = new StreamHandler('bogus://url');
- $handler->handle($this->getRecord());
- }
-
- /**
- * @expectedException UnexpectedValueException
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteNonExistingResource()
- {
- $handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000));
- $handler->handle($this->getRecord());
- }
-
- /**
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteNonExistingPath()
- {
- $handler = new StreamHandler(sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
- $handler->handle($this->getRecord());
- }
-
- /**
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteNonExistingFileResource()
- {
- $handler = new StreamHandler('file://'.sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
- $handler->handle($this->getRecord());
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionMessageRegExp /There is no existing directory at/
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteNonExistingAndNotCreatablePath()
- {
- if (defined('PHP_WINDOWS_VERSION_BUILD')) {
- $this->markTestSkipped('Permissions checks can not run on windows');
- }
- $handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
- $handler->handle($this->getRecord());
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionMessageRegExp /There is no existing directory at/
- * @covers Monolog\Handler\StreamHandler::__construct
- * @covers Monolog\Handler\StreamHandler::write
- */
- public function testWriteNonExistingAndNotCreatableFileResource()
- {
- if (defined('PHP_WINDOWS_VERSION_BUILD')) {
- $this->markTestSkipped('Permissions checks can not run on windows');
- }
- $handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000));
- $handler->handle($this->getRecord());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php
deleted file mode 100644
index 55e69c2..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-mailer = $this
- ->getMockBuilder('Swift_Mailer')
- ->disableOriginalConstructor()
- ->getMock();
- }
-
- public function testMessageCreationIsLazyWhenUsingCallback()
- {
- $this->mailer->expects($this->never())
- ->method('send');
-
- $callback = function () {
- throw new \RuntimeException('Swift_Message creation callback should not have been called in this test');
- };
- $handler = new SwiftMailerHandler($this->mailer, $callback);
-
- $records = array(
- $this->getRecord(Logger::DEBUG),
- $this->getRecord(Logger::INFO),
- );
- $handler->handleBatch($records);
- }
-
- public function testMessageCanBeCustomizedGivenLoggedData()
- {
- // Wire Mailer to expect a specific Swift_Message with a customized Subject
- $expectedMessage = new \Swift_Message();
- $this->mailer->expects($this->once())
- ->method('send')
- ->with($this->callback(function ($value) use ($expectedMessage) {
- return $value instanceof \Swift_Message
- && $value->getSubject() === 'Emergency'
- && $value === $expectedMessage;
- }));
-
- // Callback dynamically changes subject based on number of logged records
- $callback = function ($content, array $records) use ($expectedMessage) {
- $subject = count($records) > 0 ? 'Emergency' : 'Normal';
- $expectedMessage->setSubject($subject);
-
- return $expectedMessage;
- };
- $handler = new SwiftMailerHandler($this->mailer, $callback);
-
- // Logging 1 record makes this an Emergency
- $records = array(
- $this->getRecord(Logger::EMERGENCY),
- );
- $handler->handleBatch($records);
- }
-
- public function testMessageHaveUniqueId() {
- $messageTemplate = \Swift_Message::newInstance();
- $handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
-
- $method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage');
- $method->setAccessible(true);
- $method->invokeArgs($handler, array($messageTemplate, array()));
-
- $builtMessage1 = $method->invoke($handler, $messageTemplate, array());
- $builtMessage2 = $method->invoke($handler, $messageTemplate, array());
-
- $this->assertFalse($builtMessage1->getId() === $builtMessage2->getId(), 'Two different messages have the same id');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php
deleted file mode 100644
index 8f9e46b..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\Logger;
-
-class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @covers Monolog\Handler\SyslogHandler::__construct
- */
- public function testConstruct()
- {
- $handler = new SyslogHandler('test');
- $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
-
- $handler = new SyslogHandler('test', LOG_USER);
- $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
-
- $handler = new SyslogHandler('test', 'user');
- $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
-
- $handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
- $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
- }
-
- /**
- * @covers Monolog\Handler\SyslogHandler::__construct
- */
- public function testConstructInvalidFacility()
- {
- $this->setExpectedException('UnexpectedValueException');
- $handler = new SyslogHandler('test', 'unknown');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php
deleted file mode 100644
index 497812b..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-/**
- * @requires extension sockets
- */
-class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @expectedException UnexpectedValueException
- */
- public function testWeValidateFacilities()
- {
- $handler = new SyslogUdpHandler("ip", null, "invalidFacility");
- }
-
- public function testWeSplitIntoLines()
- {
- $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
- $handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
-
- $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
- $socket->expects($this->at(0))
- ->method('write')
- ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
- $socket->expects($this->at(1))
- ->method('write')
- ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
-
- $handler->setSocket($socket);
-
- $handler->handle($this->getRecordWithMessage("hej\nlol"));
- }
-
- protected function getRecordWithMessage($msg)
- {
- return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php
deleted file mode 100644
index 75cc4a8..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-/**
- * @covers Monolog\Handler\TestHandler
- */
-class TestHandlerTest extends TestCase
-{
- /**
- * @dataProvider methodProvider
- */
- public function testHandler($method, $level)
- {
- $handler = new TestHandler;
- $record = $this->getRecord($level, 'test'.$method);
- $this->assertFalse($handler->{'has'.$method}($record), 'has'.$method);
- $this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
- $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
- return true;
- }), 'has'.$method.'ThatPasses');
- $this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
- $this->assertFalse($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
- $handler->handle($record);
-
- $this->assertFalse($handler->{'has'.$method}('bar'), 'has'.$method);
- $this->assertTrue($handler->{'has'.$method}($record), 'has'.$method);
- $this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method);
- $this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
- $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
- return true;
- }), 'has'.$method.'ThatPasses');
- $this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
- $this->assertTrue($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
-
- $records = $handler->getRecords();
- unset($records[0]['formatted']);
- $this->assertEquals(array($record), $records);
- }
-
- public function methodProvider()
- {
- return array(
- array('Emergency', Logger::EMERGENCY),
- array('Alert' , Logger::ALERT),
- array('Critical' , Logger::CRITICAL),
- array('Error' , Logger::ERROR),
- array('Warning' , Logger::WARNING),
- array('Info' , Logger::INFO),
- array('Notice' , Logger::NOTICE),
- array('Debug' , Logger::DEBUG),
- );
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php
deleted file mode 100644
index fa524d0..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Handler\SyslogUdp\UdpSocket;
-
-/**
- * @requires extension sockets
- */
-class UdpSocketTest extends TestCase
-{
- public function testWeDoNotTruncateShortMessages()
- {
- $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
-
- $socket->expects($this->at(0))
- ->method('send')
- ->with("HEADER: The quick brown fox jumps over the lazy dog");
-
- $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
- }
-
- public function testLongMessagesAreTruncated()
- {
- $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
-
- $truncatedString = str_repeat("derp", 16254).'d';
-
- $socket->expects($this->exactly(1))
- ->method('send')
- ->with("HEADER" . $truncatedString);
-
- $longString = str_repeat("derp", 20000);
-
- $socket->write($longString, "HEADER");
- }
-
- public function testDoubleCloseDoesNotError()
- {
- $socket = new UdpSocket('127.0.0.1', 514);
- $socket->close();
- $socket->close();
- }
-
- /**
- * @expectedException LogicException
- */
- public function testWriteAfterCloseErrors()
- {
- $socket = new UdpSocket('127.0.0.1', 514);
- $socket->close();
- $socket->write('foo', "HEADER");
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
deleted file mode 100644
index 8d37a1f..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
+++ /dev/null
@@ -1,121 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-use Monolog\Logger;
-
-class WhatFailureGroupHandlerTest extends TestCase
-{
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::__construct
- * @expectedException InvalidArgumentException
- */
- public function testConstructorOnlyTakesHandler()
- {
- new WhatFailureGroupHandler(array(new TestHandler(), "foo"));
- }
-
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::__construct
- * @covers Monolog\Handler\WhatFailureGroupHandler::handle
- */
- public function testHandle()
- {
- $testHandlers = array(new TestHandler(), new TestHandler());
- $handler = new WhatFailureGroupHandler($testHandlers);
- $handler->handle($this->getRecord(Logger::DEBUG));
- $handler->handle($this->getRecord(Logger::INFO));
- foreach ($testHandlers as $test) {
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 2);
- }
- }
-
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch
- */
- public function testHandleBatch()
- {
- $testHandlers = array(new TestHandler(), new TestHandler());
- $handler = new WhatFailureGroupHandler($testHandlers);
- $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
- foreach ($testHandlers as $test) {
- $this->assertTrue($test->hasDebugRecords());
- $this->assertTrue($test->hasInfoRecords());
- $this->assertTrue(count($test->getRecords()) === 2);
- }
- }
-
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::isHandling
- */
- public function testIsHandling()
- {
- $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
- $handler = new WhatFailureGroupHandler($testHandlers);
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
- $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
- $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
- }
-
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::handle
- */
- public function testHandleUsesProcessors()
- {
- $test = new TestHandler();
- $handler = new WhatFailureGroupHandler(array($test));
- $handler->pushProcessor(function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-
- /**
- * @covers Monolog\Handler\WhatFailureGroupHandler::handle
- */
- public function testHandleException()
- {
- $test = new TestHandler();
- $exception = new ExceptionTestHandler();
- $handler = new WhatFailureGroupHandler(array($exception, $test, $exception));
- $handler->pushProcessor(function ($record) {
- $record['extra']['foo'] = true;
-
- return $record;
- });
- $handler->handle($this->getRecord(Logger::WARNING));
- $this->assertTrue($test->hasWarningRecords());
- $records = $test->getRecords();
- $this->assertTrue($records[0]['extra']['foo']);
- }
-}
-
-class ExceptionTestHandler extends TestHandler
-{
- /**
- * {@inheritdoc}
- */
- public function handle(array $record)
- {
- parent::handle($record);
-
- throw new \Exception("ExceptionTestHandler::handle");
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php b/application/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php
deleted file mode 100644
index 416039e..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Handler;
-
-use Monolog\TestCase;
-
-class ZendMonitorHandlerTest extends TestCase
-{
- protected $zendMonitorHandler;
-
- public function setUp()
- {
- if (!function_exists('zend_monitor_custom_event')) {
- $this->markTestSkipped('ZendServer is not installed');
- }
- }
-
- /**
- * @covers Monolog\Handler\ZendMonitorHandler::write
- */
- public function testWrite()
- {
- $record = $this->getRecord();
- $formatterResult = array(
- 'message' => $record['message']
- );
-
- $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
- ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
- ->getMock();
-
- $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
- ->disableOriginalConstructor()
- ->getMock();
-
- $formatterMock->expects($this->once())
- ->method('format')
- ->will($this->returnValue($formatterResult));
-
- $zendMonitor->expects($this->once())
- ->method('getDefaultFormatter')
- ->will($this->returnValue($formatterMock));
-
- $levelMap = $zendMonitor->getLevelMap();
-
- $zendMonitor->expects($this->once())
- ->method('writeZendMonitorCustomEvent')
- ->with($levelMap[$record['level']], $record['message'], $formatterResult);
-
- $zendMonitor->handle($record);
- }
-
- /**
- * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
- */
- public function testGetDefaultFormatterReturnsNormalizerFormatter()
- {
- $zendMonitor = new ZendMonitorHandler();
- $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/LoggerTest.php b/application/vendor/monolog/monolog/tests/Monolog/LoggerTest.php
deleted file mode 100644
index b9ba6e9..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/LoggerTest.php
+++ /dev/null
@@ -1,471 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog;
-
-use Monolog\Processor\WebProcessor;
-use Monolog\Handler\TestHandler;
-
-class LoggerTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @covers Monolog\Logger::getName
- */
- public function testGetName()
- {
- $logger = new Logger('foo');
- $this->assertEquals('foo', $logger->getName());
- }
-
- /**
- * @covers Monolog\Logger::getLevelName
- */
- public function testGetLevelName()
- {
- $this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
- }
-
- /**
- * @covers Monolog\Logger::toMonologLevel
- */
- public function testConvertPSR3ToMonologLevel()
- {
- $this->assertEquals(Logger::toMonologLevel('debug'), 100);
- $this->assertEquals(Logger::toMonologLevel('info'), 200);
- $this->assertEquals(Logger::toMonologLevel('notice'), 250);
- $this->assertEquals(Logger::toMonologLevel('warning'), 300);
- $this->assertEquals(Logger::toMonologLevel('error'), 400);
- $this->assertEquals(Logger::toMonologLevel('critical'), 500);
- $this->assertEquals(Logger::toMonologLevel('alert'), 550);
- $this->assertEquals(Logger::toMonologLevel('emergency'), 600);
- }
-
- /**
- * @covers Monolog\Logger::getLevelName
- * @expectedException InvalidArgumentException
- */
- public function testGetLevelNameThrows()
- {
- Logger::getLevelName(5);
- }
-
- /**
- * @covers Monolog\Logger::__construct
- */
- public function testChannel()
- {
- $logger = new Logger('foo');
- $handler = new TestHandler;
- $logger->pushHandler($handler);
- $logger->addWarning('test');
- list($record) = $handler->getRecords();
- $this->assertEquals('foo', $record['channel']);
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testLog()
- {
- $logger = new Logger(__METHOD__);
-
- $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'));
- $handler->expects($this->once())
- ->method('handle');
- $logger->pushHandler($handler);
-
- $this->assertTrue($logger->addWarning('test'));
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testLogNotHandled()
- {
- $logger = new Logger(__METHOD__);
-
- $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR));
- $handler->expects($this->never())
- ->method('handle');
- $logger->pushHandler($handler);
-
- $this->assertFalse($logger->addWarning('test'));
- }
-
- public function testHandlersInCtor()
- {
- $handler1 = new TestHandler;
- $handler2 = new TestHandler;
- $logger = new Logger(__METHOD__, array($handler1, $handler2));
-
- $this->assertEquals($handler1, $logger->popHandler());
- $this->assertEquals($handler2, $logger->popHandler());
- }
-
- public function testProcessorsInCtor()
- {
- $processor1 = new WebProcessor;
- $processor2 = new WebProcessor;
- $logger = new Logger(__METHOD__, array(), array($processor1, $processor2));
-
- $this->assertEquals($processor1, $logger->popProcessor());
- $this->assertEquals($processor2, $logger->popProcessor());
- }
-
- /**
- * @covers Monolog\Logger::pushHandler
- * @covers Monolog\Logger::popHandler
- * @expectedException LogicException
- */
- public function testPushPopHandler()
- {
- $logger = new Logger(__METHOD__);
- $handler1 = new TestHandler;
- $handler2 = new TestHandler;
-
- $logger->pushHandler($handler1);
- $logger->pushHandler($handler2);
-
- $this->assertEquals($handler2, $logger->popHandler());
- $this->assertEquals($handler1, $logger->popHandler());
- $logger->popHandler();
- }
-
- /**
- * @covers Monolog\Logger::setHandlers
- */
- public function testSetHandlers()
- {
- $logger = new Logger(__METHOD__);
- $handler1 = new TestHandler;
- $handler2 = new TestHandler;
-
- $logger->pushHandler($handler1);
- $logger->setHandlers(array($handler2));
-
- // handler1 has been removed
- $this->assertEquals(array($handler2), $logger->getHandlers());
-
- $logger->setHandlers(array(
- "AMapKey" => $handler1,
- "Woop" => $handler2,
- ));
-
- // Keys have been scrubbed
- $this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
- }
-
- /**
- * @covers Monolog\Logger::pushProcessor
- * @covers Monolog\Logger::popProcessor
- * @expectedException LogicException
- */
- public function testPushPopProcessor()
- {
- $logger = new Logger(__METHOD__);
- $processor1 = new WebProcessor;
- $processor2 = new WebProcessor;
-
- $logger->pushProcessor($processor1);
- $logger->pushProcessor($processor2);
-
- $this->assertEquals($processor2, $logger->popProcessor());
- $this->assertEquals($processor1, $logger->popProcessor());
- $logger->popProcessor();
- }
-
- /**
- * @covers Monolog\Logger::pushProcessor
- * @expectedException InvalidArgumentException
- */
- public function testPushProcessorWithNonCallable()
- {
- $logger = new Logger(__METHOD__);
-
- $logger->pushProcessor(new \stdClass());
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testProcessorsAreExecuted()
- {
- $logger = new Logger(__METHOD__);
- $handler = new TestHandler;
- $logger->pushHandler($handler);
- $logger->pushProcessor(function ($record) {
- $record['extra']['win'] = true;
-
- return $record;
- });
- $logger->addError('test');
- list($record) = $handler->getRecords();
- $this->assertTrue($record['extra']['win']);
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testProcessorsAreCalledOnlyOnce()
- {
- $logger = new Logger(__METHOD__);
- $handler = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler->expects($this->any())
- ->method('handle')
- ->will($this->returnValue(true))
- ;
- $logger->pushHandler($handler);
-
- $processor = $this->getMockBuilder('Monolog\Processor\WebProcessor')
- ->disableOriginalConstructor()
- ->setMethods(array('__invoke'))
- ->getMock()
- ;
- $processor->expects($this->once())
- ->method('__invoke')
- ->will($this->returnArgument(0))
- ;
- $logger->pushProcessor($processor);
-
- $logger->addError('test');
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testProcessorsNotCalledWhenNotHandled()
- {
- $logger = new Logger(__METHOD__);
- $handler = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler->expects($this->once())
- ->method('isHandling')
- ->will($this->returnValue(false))
- ;
- $logger->pushHandler($handler);
- $that = $this;
- $logger->pushProcessor(function ($record) use ($that) {
- $that->fail('The processor should not be called');
- });
- $logger->addAlert('test');
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testHandlersNotCalledBeforeFirstHandling()
- {
- $logger = new Logger(__METHOD__);
-
- $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler1->expects($this->never())
- ->method('isHandling')
- ->will($this->returnValue(false))
- ;
- $handler1->expects($this->once())
- ->method('handle')
- ->will($this->returnValue(false))
- ;
- $logger->pushHandler($handler1);
-
- $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler2->expects($this->once())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler2->expects($this->once())
- ->method('handle')
- ->will($this->returnValue(false))
- ;
- $logger->pushHandler($handler2);
-
- $handler3 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler3->expects($this->once())
- ->method('isHandling')
- ->will($this->returnValue(false))
- ;
- $handler3->expects($this->never())
- ->method('handle')
- ;
- $logger->pushHandler($handler3);
-
- $logger->debug('test');
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testBubblingWhenTheHandlerReturnsFalse()
- {
- $logger = new Logger(__METHOD__);
-
- $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler1->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler1->expects($this->once())
- ->method('handle')
- ->will($this->returnValue(false))
- ;
- $logger->pushHandler($handler1);
-
- $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler2->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler2->expects($this->once())
- ->method('handle')
- ->will($this->returnValue(false))
- ;
- $logger->pushHandler($handler2);
-
- $logger->debug('test');
- }
-
- /**
- * @covers Monolog\Logger::addRecord
- */
- public function testNotBubblingWhenTheHandlerReturnsTrue()
- {
- $logger = new Logger(__METHOD__);
-
- $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler1->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler1->expects($this->never())
- ->method('handle')
- ;
- $logger->pushHandler($handler1);
-
- $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler2->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
- $handler2->expects($this->once())
- ->method('handle')
- ->will($this->returnValue(true))
- ;
- $logger->pushHandler($handler2);
-
- $logger->debug('test');
- }
-
- /**
- * @covers Monolog\Logger::isHandling
- */
- public function testIsHandling()
- {
- $logger = new Logger(__METHOD__);
-
- $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler1->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(false))
- ;
-
- $logger->pushHandler($handler1);
- $this->assertFalse($logger->isHandling(Logger::DEBUG));
-
- $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
- $handler2->expects($this->any())
- ->method('isHandling')
- ->will($this->returnValue(true))
- ;
-
- $logger->pushHandler($handler2);
- $this->assertTrue($logger->isHandling(Logger::DEBUG));
- }
-
- /**
- * @dataProvider logMethodProvider
- * @covers Monolog\Logger::addDebug
- * @covers Monolog\Logger::addInfo
- * @covers Monolog\Logger::addNotice
- * @covers Monolog\Logger::addWarning
- * @covers Monolog\Logger::addError
- * @covers Monolog\Logger::addCritical
- * @covers Monolog\Logger::addAlert
- * @covers Monolog\Logger::addEmergency
- * @covers Monolog\Logger::debug
- * @covers Monolog\Logger::info
- * @covers Monolog\Logger::notice
- * @covers Monolog\Logger::warn
- * @covers Monolog\Logger::err
- * @covers Monolog\Logger::crit
- * @covers Monolog\Logger::alert
- * @covers Monolog\Logger::emerg
- */
- public function testLogMethods($method, $expectedLevel)
- {
- $logger = new Logger('foo');
- $handler = new TestHandler;
- $logger->pushHandler($handler);
- $logger->{$method}('test');
- list($record) = $handler->getRecords();
- $this->assertEquals($expectedLevel, $record['level']);
- }
-
- public function logMethodProvider()
- {
- return array(
- // monolog methods
- array('addDebug', Logger::DEBUG),
- array('addInfo', Logger::INFO),
- array('addNotice', Logger::NOTICE),
- array('addWarning', Logger::WARNING),
- array('addError', Logger::ERROR),
- array('addCritical', Logger::CRITICAL),
- array('addAlert', Logger::ALERT),
- array('addEmergency', Logger::EMERGENCY),
-
- // ZF/Sf2 compat methods
- array('debug', Logger::DEBUG),
- array('info', Logger::INFO),
- array('notice', Logger::NOTICE),
- array('warn', Logger::WARNING),
- array('err', Logger::ERROR),
- array('crit', Logger::CRITICAL),
- array('alert', Logger::ALERT),
- array('emerg', Logger::EMERGENCY),
- );
- }
-
- /**
- * @dataProvider setTimezoneProvider
- * @covers Monolog\Logger::setTimezone
- */
- public function testSetTimezone($tz)
- {
- Logger::setTimezone($tz);
- $logger = new Logger('foo');
- $handler = new TestHandler;
- $logger->pushHandler($handler);
- $logger->info('test');
- list($record) = $handler->getRecords();
- $this->assertEquals($tz, $record['datetime']->getTimezone());
- }
-
- public function setTimezoneProvider()
- {
- return array_map(
- function ($tz) { return array(new \DateTimeZone($tz)); },
- \DateTimeZone::listIdentifiers()
- );
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php
deleted file mode 100644
index 5adb505..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class GitProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\GitProcessor::__invoke
- */
- public function testProcessor()
- {
- $processor = new GitProcessor();
- $record = $processor($this->getRecord());
-
- $this->assertArrayHasKey('git', $record['extra']);
- $this->assertTrue(!is_array($record['extra']['git']['branch']));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php
deleted file mode 100644
index 0dd411d..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php
+++ /dev/null
@@ -1,123 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Acme;
-
-class Tester
-{
- public function test($handler, $record)
- {
- $handler->handle($record);
- }
-}
-
-function tester($handler, $record)
-{
- $handler->handle($record);
-}
-
-namespace Monolog\Processor;
-
-use Monolog\Logger;
-use Monolog\TestCase;
-use Monolog\Handler\TestHandler;
-
-class IntrospectionProcessorTest extends TestCase
-{
- public function getHandler()
- {
- $processor = new IntrospectionProcessor();
- $handler = new TestHandler();
- $handler->pushProcessor($processor);
-
- return $handler;
- }
-
- public function testProcessorFromClass()
- {
- $handler = $this->getHandler();
- $tester = new \Acme\Tester;
- $tester->test($handler, $this->getRecord());
- list($record) = $handler->getRecords();
- $this->assertEquals(__FILE__, $record['extra']['file']);
- $this->assertEquals(18, $record['extra']['line']);
- $this->assertEquals('Acme\Tester', $record['extra']['class']);
- $this->assertEquals('test', $record['extra']['function']);
- }
-
- public function testProcessorFromFunc()
- {
- $handler = $this->getHandler();
- \Acme\tester($handler, $this->getRecord());
- list($record) = $handler->getRecords();
- $this->assertEquals(__FILE__, $record['extra']['file']);
- $this->assertEquals(24, $record['extra']['line']);
- $this->assertEquals(null, $record['extra']['class']);
- $this->assertEquals('Acme\tester', $record['extra']['function']);
- }
-
- public function testLevelTooLow()
- {
- $input = array(
- 'level' => Logger::DEBUG,
- 'extra' => array(),
- );
-
- $expected = $input;
-
- $processor = new IntrospectionProcessor(Logger::CRITICAL);
- $actual = $processor($input);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testLevelEqual()
- {
- $input = array(
- 'level' => Logger::CRITICAL,
- 'extra' => array(),
- );
-
- $expected = $input;
- $expected['extra'] = array(
- 'file' => null,
- 'line' => null,
- 'class' => 'ReflectionMethod',
- 'function' => 'invokeArgs',
- );
-
- $processor = new IntrospectionProcessor(Logger::CRITICAL);
- $actual = $processor($input);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testLevelHigher()
- {
- $input = array(
- 'level' => Logger::EMERGENCY,
- 'extra' => array(),
- );
-
- $expected = $input;
- $expected['extra'] = array(
- 'file' => null,
- 'line' => null,
- 'class' => 'ReflectionMethod',
- 'function' => 'invokeArgs',
- );
-
- $processor = new IntrospectionProcessor(Logger::CRITICAL);
- $actual = $processor($input);
-
- $this->assertEquals($expected, $actual);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
deleted file mode 100644
index eb66614..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class MemoryPeakUsageProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
- * @covers Monolog\Processor\MemoryProcessor::formatBytes
- */
- public function testProcessor()
- {
- $processor = new MemoryPeakUsageProcessor();
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
- $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']);
- }
-
- /**
- * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
- * @covers Monolog\Processor\MemoryProcessor::formatBytes
- */
- public function testProcessorWithoutFormatting()
- {
- $processor = new MemoryPeakUsageProcessor(true, false);
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
- $this->assertInternalType('int', $record['extra']['memory_peak_usage']);
- $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php
deleted file mode 100644
index 4692dbf..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class MemoryUsageProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
- * @covers Monolog\Processor\MemoryProcessor::formatBytes
- */
- public function testProcessor()
- {
- $processor = new MemoryUsageProcessor();
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('memory_usage', $record['extra']);
- $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']);
- }
-
- /**
- * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
- * @covers Monolog\Processor\MemoryProcessor::formatBytes
- */
- public function testProcessorWithoutFormatting()
- {
- $processor = new MemoryUsageProcessor(true, false);
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('memory_usage', $record['extra']);
- $this->assertInternalType('int', $record['extra']['memory_usage']);
- $this->assertGreaterThan(0, $record['extra']['memory_usage']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php
deleted file mode 100644
index 458d2a3..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class ProcessIdProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\ProcessIdProcessor::__invoke
- */
- public function testProcessor()
- {
- $processor = new ProcessIdProcessor();
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('process_id', $record['extra']);
- $this->assertInternalType('int', $record['extra']['process_id']);
- $this->assertGreaterThan(0, $record['extra']['process_id']);
- $this->assertEquals(getmypid(), $record['extra']['process_id']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php
deleted file mode 100644
index 81bfbdc..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @dataProvider getPairs
- */
- public function testReplacement($val, $expected)
- {
- $proc = new PsrLogMessageProcessor;
-
- $message = $proc(array(
- 'message' => '{foo}',
- 'context' => array('foo' => $val)
- ));
- $this->assertEquals($expected, $message['message']);
- }
-
- public function getPairs()
- {
- return array(
- array('foo', 'foo'),
- array('3', '3'),
- array(3, '3'),
- array(null, ''),
- array(true, '1'),
- array(false, ''),
- array(new \stdClass, '[object stdClass]'),
- array(array(), '[array]'),
- );
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php
deleted file mode 100644
index 0d860c6..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class TagProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\TagProcessor::__invoke
- */
- public function testProcessor()
- {
- $tags = array(1, 2, 3);
- $processor = new TagProcessor($tags);
- $record = $processor($this->getRecord());
-
- $this->assertEquals($tags, $record['extra']['tags']);
- }
-
- /**
- * @covers Monolog\Processor\TagProcessor::__invoke
- */
- public function testProcessorTagModification()
- {
- $tags = array(1, 2, 3);
- $processor = new TagProcessor($tags);
-
- $record = $processor($this->getRecord());
- $this->assertEquals($tags, $record['extra']['tags']);
-
- $processor->setTags(array('a', 'b'));
- $record = $processor($this->getRecord());
- $this->assertEquals(array('a', 'b'), $record['extra']['tags']);
-
- $processor->addTags(array('a', 'c', 'foo' => 'bar'));
- $record = $processor($this->getRecord());
- $this->assertEquals(array('a', 'b', 'a', 'c', 'foo' => 'bar'), $record['extra']['tags']);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php
deleted file mode 100644
index befad95..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class UidProcessorTest extends TestCase
-{
- /**
- * @covers Monolog\Processor\UidProcessor::__invoke
- */
- public function testProcessor()
- {
- $processor = new UidProcessor();
- $record = $processor($this->getRecord());
- $this->assertArrayHasKey('uid', $record['extra']);
- }
- public function testGetUid()
- {
- $processor = new UidProcessor(10);
- $this->assertEquals(10, strlen($processor->getUid()));
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php b/application/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php
deleted file mode 100644
index dba8941..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog\Processor;
-
-use Monolog\TestCase;
-
-class WebProcessorTest extends TestCase
-{
- public function testProcessor()
- {
- $server = array(
- 'REQUEST_URI' => 'A',
- 'REMOTE_ADDR' => 'B',
- 'REQUEST_METHOD' => 'C',
- 'HTTP_REFERER' => 'D',
- 'SERVER_NAME' => 'F',
- 'UNIQUE_ID' => 'G',
- );
-
- $processor = new WebProcessor($server);
- $record = $processor($this->getRecord());
- $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
- $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
- $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
- $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
- $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
- $this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']);
- }
-
- public function testProcessorDoNothingIfNoRequestUri()
- {
- $server = array(
- 'REMOTE_ADDR' => 'B',
- 'REQUEST_METHOD' => 'C',
- );
- $processor = new WebProcessor($server);
- $record = $processor($this->getRecord());
- $this->assertEmpty($record['extra']);
- }
-
- public function testProcessorReturnNullIfNoHttpReferer()
- {
- $server = array(
- 'REQUEST_URI' => 'A',
- 'REMOTE_ADDR' => 'B',
- 'REQUEST_METHOD' => 'C',
- 'SERVER_NAME' => 'F',
- );
- $processor = new WebProcessor($server);
- $record = $processor($this->getRecord());
- $this->assertNull($record['extra']['referrer']);
- }
-
- public function testProcessorDoesNotAddUniqueIdIfNotPresent()
- {
- $server = array(
- 'REQUEST_URI' => 'A',
- 'REMOTE_ADDR' => 'B',
- 'REQUEST_METHOD' => 'C',
- 'SERVER_NAME' => 'F',
- );
- $processor = new WebProcessor($server);
- $record = $processor($this->getRecord());
- $this->assertFalse(isset($record['extra']['unique_id']));
- }
-
- public function testProcessorAddsOnlyRequestedExtraFields()
- {
- $server = array(
- 'REQUEST_URI' => 'A',
- 'REMOTE_ADDR' => 'B',
- 'REQUEST_METHOD' => 'C',
- 'SERVER_NAME' => 'F',
- );
-
- $processor = new WebProcessor($server, array('url', 'http_method'));
- $record = $processor($this->getRecord());
-
- $this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
- }
-
- /**
- * @expectedException UnexpectedValueException
- */
- public function testInvalidData()
- {
- new WebProcessor(new \stdClass);
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php b/application/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
deleted file mode 100644
index ab89944..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog;
-
-use Monolog\Handler\TestHandler;
-use Monolog\Formatter\LineFormatter;
-use Monolog\Processor\PsrLogMessageProcessor;
-use Psr\Log\Test\LoggerInterfaceTest;
-
-class PsrLogCompatTest extends LoggerInterfaceTest
-{
- private $handler;
-
- public function getLogger()
- {
- $logger = new Logger('foo');
- $logger->pushHandler($handler = new TestHandler);
- $logger->pushProcessor(new PsrLogMessageProcessor);
- $handler->setFormatter(new LineFormatter('%level_name% %message%'));
-
- $this->handler = $handler;
-
- return $logger;
- }
-
- public function getLogs()
- {
- $convert = function ($record) {
- $lower = function ($match) {
- return strtolower($match[0]);
- };
-
- return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']);
- };
-
- return array_map($convert, $this->handler->getRecords());
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/RegistryTest.php b/application/vendor/monolog/monolog/tests/Monolog/RegistryTest.php
deleted file mode 100644
index 15fdfbd..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/RegistryTest.php
+++ /dev/null
@@ -1,153 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog;
-
-class RegistryTest extends \PHPUnit_Framework_TestCase
-{
- protected function setUp()
- {
- Registry::clear();
- }
-
- /**
- * @dataProvider hasLoggerProvider
- * @covers Monolog\Registry::hasLogger
- */
- public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
- {
- foreach ($loggersToAdd as $loggerToAdd) {
- Registry::addLogger($loggerToAdd);
- }
- foreach ($loggersToCheck as $index => $loggerToCheck) {
- $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck));
- }
- }
-
- public function hasLoggerProvider()
- {
- $logger1 = new Logger('test1');
- $logger2 = new Logger('test2');
- $logger3 = new Logger('test3');
-
- return array(
- // only instances
- array(
- array($logger1),
- array($logger1, $logger2),
- array(true, false),
- ),
- // only names
- array(
- array($logger1),
- array('test1', 'test2'),
- array(true, false),
- ),
- // mixed case
- array(
- array($logger1, $logger2),
- array('test1', $logger2, 'test3', $logger3),
- array(true, true, false, false),
- ),
- );
- }
-
- /**
- * @covers Monolog\Registry::clear
- */
- public function testClearClears()
- {
- Registry::addLogger(new Logger('test1'), 'log');
- Registry::clear();
-
- $this->setExpectedException('\InvalidArgumentException');
- Registry::getInstance('log');
- }
-
- /**
- * @dataProvider removedLoggerProvider
- * @covers Monolog\Registry::addLogger
- * @covers Monolog\Registry::removeLogger
- */
- public function testRemovesLogger($loggerToAdd, $remove)
- {
- Registry::addLogger($loggerToAdd);
- Registry::removeLogger($remove);
-
- $this->setExpectedException('\InvalidArgumentException');
- Registry::getInstance($loggerToAdd->getName());
- }
-
- public function removedLoggerProvider()
- {
- $logger1 = new Logger('test1');
-
- return array(
- array($logger1, $logger1),
- array($logger1, 'test1'),
- );
- }
-
- /**
- * @covers Monolog\Registry::addLogger
- * @covers Monolog\Registry::getInstance
- * @covers Monolog\Registry::__callStatic
- */
- public function testGetsSameLogger()
- {
- $logger1 = new Logger('test1');
- $logger2 = new Logger('test2');
-
- Registry::addLogger($logger1, 'test1');
- Registry::addLogger($logger2);
-
- $this->assertSame($logger1, Registry::getInstance('test1'));
- $this->assertSame($logger2, Registry::test2());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @covers Monolog\Registry::getInstance
- */
- public function testFailsOnNonExistantLogger()
- {
- Registry::getInstance('test1');
- }
-
- /**
- * @covers Monolog\Registry::addLogger
- */
- public function testReplacesLogger()
- {
- $log1 = new Logger('test1');
- $log2 = new Logger('test2');
-
- Registry::addLogger($log1, 'log');
-
- Registry::addLogger($log2, 'log', true);
-
- $this->assertSame($log2, Registry::getInstance('log'));
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @covers Monolog\Registry::addLogger
- */
- public function testFailsOnUnspecifiedReplacement()
- {
- $log1 = new Logger('test1');
- $log2 = new Logger('test2');
-
- Registry::addLogger($log1, 'log');
-
- Registry::addLogger($log2, 'log');
- }
-}
diff --git a/application/vendor/monolog/monolog/tests/Monolog/TestCase.php b/application/vendor/monolog/monolog/tests/Monolog/TestCase.php
deleted file mode 100644
index cae7934..0000000
--- a/application/vendor/monolog/monolog/tests/Monolog/TestCase.php
+++ /dev/null
@@ -1,58 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Monolog;
-
-class TestCase extends \PHPUnit_Framework_TestCase
-{
- /**
- * @return array Record
- */
- protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
- {
- return array(
- 'message' => $message,
- 'context' => $context,
- 'level' => $level,
- 'level_name' => Logger::getLevelName($level),
- 'channel' => 'test',
- 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
- 'extra' => array(),
- );
- }
-
- /**
- * @return array
- */
- protected function getMultipleRecords()
- {
- return array(
- $this->getRecord(Logger::DEBUG, 'debug message 1'),
- $this->getRecord(Logger::DEBUG, 'debug message 2'),
- $this->getRecord(Logger::INFO, 'information'),
- $this->getRecord(Logger::WARNING, 'warning'),
- $this->getRecord(Logger::ERROR, 'error')
- );
- }
-
- /**
- * @return Monolog\Formatter\FormatterInterface
- */
- protected function getIdentityFormatter()
- {
- $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
- $formatter->expects($this->any())
- ->method('format')
- ->will($this->returnCallback(function ($record) { return $record['message']; }));
-
- return $formatter;
- }
-}
diff --git a/application/vendor/mtdowling/cron-expression/CHANGELOG.md b/application/vendor/mtdowling/cron-expression/CHANGELOG.md
new file mode 100644
index 0000000..8ddab90
--- /dev/null
+++ b/application/vendor/mtdowling/cron-expression/CHANGELOG.md
@@ -0,0 +1,36 @@
+# Change Log
+
+## [1.2.0] - 2017-01-22
+### Added
+- Added IDE, CodeSniffer, and StyleCI.IO support
+
+### Changed
+- Switched to PSR-4 Autoloading
+
+### Fixed
+- 0 step expressions are handled better
+- Fixed `DayOfMonth` validation to be more strict
+- Typos
+
+## [1.1.0] - 2016-01-26
+### Added
+- Support for non-hourly offset timezones
+- Checks for valid expressions
+
+### Changed
+- Max Iterations no longer hardcoded for `getRunDate()`
+- Supports DateTimeImmutable for newer PHP verions
+
+### Fixed
+- Fixed looping bug for PHP 7 when determining the last specified weekday of a month
+
+## [1.0.3] - 2013-11-23
+### Added
+- Now supports expressions with any number of extra spaces, tabs, or newlines
+
+### Changed
+- Using static instead of self in `CronExpression::factory`
+
+### Fixed
+- Fixes issue [#28](https://github.com/mtdowling/cron-expression/issues/28) where PHP increments of ranges were failing due to PHP casting hyphens to 0
+- Only set default timezone if the given $currentTime is not a DateTime instance ([#34](https://github.com/mtdowling/cron-expression/issues/34))
diff --git a/application/vendor/mtdowling/cron-expression/README.md b/application/vendor/mtdowling/cron-expression/README.md
index 1571e5d..c9e3bf3 100644
--- a/application/vendor/mtdowling/cron-expression/README.md
+++ b/application/vendor/mtdowling/cron-expression/README.md
@@ -68,15 +68,4 @@ Requirements
- PHP 5.3+
- PHPUnit is required to run the unit tests
-- Composer is required to run the unit tests
-
-CHANGELOG
-=========
-
-1.0.3 (2013-11-23)
-------------------
-
-* Only set default timezone if the given $currentTime is not a DateTime instance ([#34](https://github.com/mtdowling/cron-expression/issues/34))
-* Fixes issue [#28](https://github.com/mtdowling/cron-expression/issues/28) where PHP increments of ranges were failing due to PHP casting hyphens to 0
-* Now supports expressions with any number of extra spaces, tabs, or newlines
-* Using static instead of self in `CronExpression::factory`
+- Composer is required to run the unit tests
\ No newline at end of file
diff --git a/application/vendor/mtdowling/cron-expression/composer.json b/application/vendor/mtdowling/cron-expression/composer.json
index 62c0d89..ce42d40 100644
--- a/application/vendor/mtdowling/cron-expression/composer.json
+++ b/application/vendor/mtdowling/cron-expression/composer.json
@@ -13,11 +13,16 @@
"php": ">=5.3.2"
},
"require-dev": {
- "phpunit/phpunit": "4.*"
+ "phpunit/phpunit": "~4.0|~5.0"
},
"autoload": {
- "psr-0": {
- "Cron": "src/"
+ "psr-4": {
+ "Cron\\": "src/Cron/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Tests\\": "tests/Cron/"
}
}
}
\ No newline at end of file
diff --git a/application/vendor/mtdowling/cron-expression/phpunit.xml.dist b/application/vendor/mtdowling/cron-expression/phpunit.xml.dist
deleted file mode 100644
index fb8a552..0000000
--- a/application/vendor/mtdowling/cron-expression/phpunit.xml.dist
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- ./tests
-
-
-
-
-
- ./src/Cron
-
-
-
-
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/AbstractField.php b/application/vendor/mtdowling/cron-expression/src/Cron/AbstractField.php
index c0616a2..cd2410a 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/AbstractField.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/AbstractField.php
@@ -76,8 +76,13 @@ public function isInRange($dateValue, $value)
public function isInIncrementsOfRanges($dateValue, $value)
{
$parts = array_map('trim', explode('/', $value, 2));
- $stepSize = isset($parts[1]) ? $parts[1] : 0;
- if (($parts[0] == '*' || $parts[0] === '0') && 0 !== $stepSize) {
+ $stepSize = isset($parts[1]) ? (int) $parts[1] : 0;
+
+ if ($stepSize === 0) {
+ return false;
+ }
+
+ if (($parts[0] == '*' || $parts[0] === '0')) {
return (int) $dateValue % $stepSize == 0;
}
@@ -101,4 +106,43 @@ public function isInIncrementsOfRanges($dateValue, $value)
return false;
}
+
+ /**
+ * Returns a range of values for the given cron expression
+ *
+ * @param string $expression The expression to evaluate
+ * @param int $max Maximum offset for range
+ *
+ * @return array
+ */
+ public function getRangeForExpression($expression, $max)
+ {
+ $values = array();
+
+ if ($this->isRange($expression) || $this->isIncrementsOfRanges($expression)) {
+ if (!$this->isIncrementsOfRanges($expression)) {
+ list ($offset, $to) = explode('-', $expression);
+ $stepSize = 1;
+ }
+ else {
+ $range = array_map('trim', explode('/', $expression, 2));
+ $stepSize = isset($range[1]) ? $range[1] : 0;
+ $range = $range[0];
+ $range = explode('-', $range, 2);
+ $offset = $range[0];
+ $to = isset($range[1]) ? $range[1] : $max;
+ }
+ $offset = $offset == '*' ? 0 : $offset;
+ for ($i = $offset; $i <= $to; $i += $stepSize) {
+ $values[] = $i;
+ }
+ sort($values);
+ }
+ else {
+ $values = array($expression);
+ }
+
+ return $values;
+ }
+
}
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php b/application/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php
index ce90f29..d69b415 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php
@@ -2,6 +2,13 @@
namespace Cron;
+use DateTime;
+use DateTimeImmutable;
+use DateTimeZone;
+use Exception;
+use InvalidArgumentException;
+use RuntimeException;
+
/**
* CRON expression parser that can determine whether or not a CRON expression is
* due to run, the next run date and previous run date of a CRON expression.
@@ -33,6 +40,11 @@ class CronExpression
*/
private $fieldFactory;
+ /**
+ * @var int Max iteration count when searching for next run date
+ */
+ private $maxIterationCount = 1000;
+
/**
* @var array Order in which to test of cron parts
*/
@@ -72,6 +84,25 @@ public static function factory($expression, FieldFactory $fieldFactory = null)
return new static($expression, $fieldFactory ?: new FieldFactory());
}
+ /**
+ * Validate a CronExpression.
+ *
+ * @param string $expression The CRON expression to validate.
+ *
+ * @return bool True if a valid CRON expression was passed. False if not.
+ * @see \Cron\CronExpression::factory
+ */
+ public static function isValidExpression($expression)
+ {
+ try {
+ self::factory($expression);
+ } catch (InvalidArgumentException $e) {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Parse a CRON expression
*
@@ -96,7 +127,7 @@ public function setExpression($value)
{
$this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
if (count($this->cronParts) < 5) {
- throw new \InvalidArgumentException(
+ throw new InvalidArgumentException(
$value . ' is not a valid CRON expression'
);
}
@@ -120,8 +151,8 @@ public function setExpression($value)
public function setPart($position, $value)
{
if (!$this->fieldFactory->getField($position)->validate($value)) {
- throw new \InvalidArgumentException(
- 'Invalid CRON field value ' . $value . ' as position ' . $position
+ throw new InvalidArgumentException(
+ 'Invalid CRON field value ' . $value . ' at position ' . $position
);
}
@@ -130,6 +161,20 @@ public function setPart($position, $value)
return $this;
}
+ /**
+ * Set max iteration count for searching next run dates
+ *
+ * @param int $maxIterationCount Max iteration count when searching for next run date
+ *
+ * @return CronExpression
+ */
+ public function setMaxIterationCount($maxIterationCount)
+ {
+ $this->maxIterationCount = $maxIterationCount;
+
+ return $this;
+ }
+
/**
* Get a next run date relative to the current date or a specific date
*
@@ -161,7 +206,7 @@ public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate
*
* @return \DateTime
* @throws \RuntimeException on too many iterations
- * @see Cron\CronExpression::getNextRunDate
+ * @see \Cron\CronExpression::getNextRunDate
*/
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
{
@@ -183,7 +228,11 @@ public function getMultipleRunDates($total, $currentTime = 'now', $invert = fals
{
$matches = array();
for ($i = 0; $i < max(0, $total); $i++) {
- $matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate);
+ try {
+ $matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate);
+ } catch (RuntimeException $e) {
+ break;
+ }
}
return $matches;
@@ -233,14 +282,19 @@ public function isDue($currentTime = 'now')
if ('now' === $currentTime) {
$currentDate = date('Y-m-d H:i');
$currentTime = strtotime($currentDate);
- } elseif ($currentTime instanceof \DateTime) {
+ } elseif ($currentTime instanceof DateTime) {
$currentDate = clone $currentTime;
// Ensure time in 'current' timezone is used
- $currentDate->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+ $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
+ $currentDate = $currentDate->format('Y-m-d H:i');
+ $currentTime = strtotime($currentDate);
+ } elseif ($currentTime instanceof DateTimeImmutable) {
+ $currentDate = DateTime::createFromFormat('U', $currentTime->format('U'));
+ $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
$currentDate = $currentDate->format('Y-m-d H:i');
$currentTime = strtotime($currentDate);
} else {
- $currentTime = new \DateTime($currentTime);
+ $currentTime = new DateTime($currentTime);
$currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0);
$currentDate = $currentTime->format('Y-m-d H:i');
$currentTime = $currentTime->getTimeStamp();
@@ -248,7 +302,7 @@ public function isDue($currentTime = 'now')
try {
return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
return false;
}
}
@@ -267,11 +321,14 @@ public function isDue($currentTime = 'now')
*/
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false)
{
- if ($currentTime instanceof \DateTime) {
+ if ($currentTime instanceof DateTime) {
$currentDate = clone $currentTime;
+ } elseif ($currentTime instanceof DateTimeImmutable) {
+ $currentDate = DateTime::createFromFormat('U', $currentTime->format('U'));
+ $currentDate->setTimezone($currentTime->getTimezone());
} else {
- $currentDate = new \DateTime($currentTime ?: 'now');
- $currentDate->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+ $currentDate = new DateTime($currentTime ?: 'now');
+ $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
}
$currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0);
@@ -291,7 +348,7 @@ protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $a
}
// Set a hard limit to bail on an impossible date
- for ($i = 0; $i < 1000; $i++) {
+ for ($i = 0; $i < $this->maxIterationCount; $i++) {
foreach ($parts as $position => $part) {
$satisfied = false;
@@ -311,14 +368,14 @@ protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $a
// If the field is not satisfied, then start over
if (!$satisfied) {
- $field->increment($nextRun, $invert);
+ $field->increment($nextRun, $invert, $part);
continue 2;
}
}
// Skip this match if needed
if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) {
- $this->fieldFactory->getField(0)->increment($nextRun, $invert);
+ $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null);
continue;
}
@@ -326,7 +383,7 @@ protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $a
}
// @codeCoverageIgnoreStart
- throw new \RuntimeException('Impossible CRON expression');
+ throw new RuntimeException('Impossible CRON expression');
// @codeCoverageIgnoreEnd
}
}
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/DayOfMonthField.php b/application/vendor/mtdowling/cron-expression/src/Cron/DayOfMonthField.php
index 86129c9..53e15bc 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/DayOfMonthField.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/DayOfMonthField.php
@@ -2,6 +2,8 @@
namespace Cron;
+use DateTime;
+
/**
* Day of month field. Allows: * , / - ? L W
*
@@ -34,7 +36,7 @@ class DayOfMonthField extends AbstractField
private static function getNearestWeekday($currentYear, $currentMonth, $targetDay)
{
$tday = str_pad($targetDay, 2, '0', STR_PAD_LEFT);
- $target = \DateTime::createFromFormat('Y-m-d', "$currentYear-$currentMonth-$tday");
+ $target = DateTime::createFromFormat('Y-m-d', "$currentYear-$currentMonth-$tday");
$currentWeekday = (int) $target->format('N');
if ($currentWeekday < 6) {
@@ -54,7 +56,7 @@ private static function getNearestWeekday($currentYear, $currentMonth, $targetDa
}
}
- public function isSatisfiedBy(\DateTime $date, $value)
+ public function isSatisfiedBy(DateTime $date, $value)
{
// ? states that the field value is to be skipped
if ($value == '?') {
@@ -83,7 +85,7 @@ public function isSatisfiedBy(\DateTime $date, $value)
return $this->isSatisfied($date->format('d'), $value);
}
- public function increment(\DateTime $date, $invert = false)
+ public function increment(DateTime $date, $invert = false)
{
if ($invert) {
$date->modify('previous day');
@@ -96,8 +98,76 @@ public function increment(\DateTime $date, $invert = false)
return $this;
}
+ /**
+ * Validates that the value is valid for the Day of the Month field
+ * Days of the month can contain values of 1-31, *, L, or ? by default. This can be augmented with lists via a ',',
+ * ranges via a '-', or with a '[0-9]W' to specify the closest weekday.
+ *
+ * @param string $value
+ * @return bool
+ */
public function validate($value)
{
- return (bool) preg_match('/^[\*,\/\-\?LW0-9A-Za-z]+$/', $value);
+ // Allow wildcards and a single L
+ if ($value === '?' || $value === '*' || $value === 'L') {
+ return true;
+ }
+
+ // If you only contain numbers and are within 1-31
+ if ((bool) preg_match('/^\d{1,2}$/', $value) && ($value >= 1 && $value <= 31)) {
+ return true;
+ }
+
+ // If you have a -, we will deal with each of your chunks
+ if ((bool) preg_match('/-/', $value)) {
+ // We cannot have a range within a list or vice versa
+ if ((bool) preg_match('/,/', $value)) {
+ return false;
+ }
+
+ $chunks = explode('-', $value);
+ foreach ($chunks as $chunk) {
+ if (!$this->validate($chunk)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // If you have a comma, we will deal with each value
+ if ((bool) preg_match('/,/', $value)) {
+ // We cannot have a range within a list or vice versa
+ if ((bool) preg_match('/-/', $value)) {
+ return false;
+ }
+
+ $chunks = explode(',', $value);
+ foreach ($chunks as $chunk) {
+ if (!$this->validate($chunk)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // If you contain a /, we'll deal with it
+ if ((bool) preg_match('/\//', $value)) {
+ $chunks = explode('/', $value);
+ foreach ($chunks as $chunk) {
+ if (!$this->validate($chunk)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // If you end in W, make sure that it has a numeric in front of it
+ if ((bool) preg_match('/^\d{1,2}W$/', $value)) {
+ return true;
+ }
+
+ return false;
}
}
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/DayOfWeekField.php b/application/vendor/mtdowling/cron-expression/src/Cron/DayOfWeekField.php
index 8e33b19..83e2f4c 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/DayOfWeekField.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/DayOfWeekField.php
@@ -2,6 +2,10 @@
namespace Cron;
+use DateTime;
+use InvalidArgumentException;
+
+
/**
* Day of week field. Allows: * / , - ? L #
*
@@ -17,7 +21,7 @@
*/
class DayOfWeekField extends AbstractField
{
- public function isSatisfiedBy(\DateTime $date, $value)
+ public function isSatisfiedBy(DateTime $date, $value)
{
if ($value == '?') {
return true;
@@ -36,7 +40,10 @@ public function isSatisfiedBy(\DateTime $date, $value)
$tdate = clone $date;
$tdate->setDate($currentYear, $currentMonth, $lastDayOfMonth);
while ($tdate->format('w') != $weekday) {
- $tdate->setDate($currentYear, $currentMonth, --$lastDayOfMonth);
+ $tdateClone = new DateTime();
+ $tdate = $tdateClone
+ ->setTimezone($tdate->getTimezone())
+ ->setDate($currentYear, $currentMonth, --$lastDayOfMonth);
}
return $date->format('j') == $lastDayOfMonth;
@@ -53,10 +60,10 @@ public function isSatisfiedBy(\DateTime $date, $value)
// Validate the hash fields
if ($weekday < 0 || $weekday > 7) {
- throw new \InvalidArgumentException("Weekday must be a value between 0 and 7. {$weekday} given");
+ throw new InvalidArgumentException("Weekday must be a value between 0 and 7. {$weekday} given");
}
if ($nth > 5) {
- throw new \InvalidArgumentException('There are never more than 5 of a given weekday in a month');
+ throw new InvalidArgumentException('There are never more than 5 of a given weekday in a month');
}
// The current weekday must match the targeted weekday to proceed
if ($date->format('N') != $weekday) {
@@ -97,7 +104,7 @@ public function isSatisfiedBy(\DateTime $date, $value)
return $this->isSatisfied($fieldValue, $value);
}
- public function increment(\DateTime $date, $invert = false)
+ public function increment(DateTime $date, $invert = false)
{
if ($invert) {
$date->modify('-1 day');
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/FieldFactory.php b/application/vendor/mtdowling/cron-expression/src/Cron/FieldFactory.php
index 5aa86f6..fa0e6fe 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/FieldFactory.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/FieldFactory.php
@@ -2,6 +2,8 @@
namespace Cron;
+use InvalidArgumentException;
+
/**
* CRON field factory implementing a flyweight factory
* @link http://en.wikipedia.org/wiki/Cron
@@ -44,7 +46,7 @@ public function getField($position)
$this->fields[$position] = new YearField();
break;
default:
- throw new \InvalidArgumentException(
+ throw new InvalidArgumentException(
$position . ' is not a valid position'
);
}
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/FieldInterface.php b/application/vendor/mtdowling/cron-expression/src/Cron/FieldInterface.php
index 3823fbf..be37b93 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/FieldInterface.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/FieldInterface.php
@@ -1,6 +1,7 @@
isSatisfied($date->format('H'), $value);
}
- public function increment(\DateTime $date, $invert = false)
+ public function increment(DateTime $date, $invert = false, $parts = null)
{
// Change timezone to UTC temporarily. This will
// allow us to go back or forwards and hour even
// if DST will be changed between the hours.
- $timezone = $date->getTimezone();
- $date->setTimezone(new \DateTimeZone('UTC'));
- if ($invert) {
- $date->modify('-1 hour');
- $date->setTime($date->format('H'), 59);
- } else {
- $date->modify('+1 hour');
- $date->setTime($date->format('H'), 0);
+ if (is_null($parts) || $parts == '*') {
+ $timezone = $date->getTimezone();
+ $date->setTimezone(new DateTimeZone('UTC'));
+ if ($invert) {
+ $date->modify('-1 hour');
+ } else {
+ $date->modify('+1 hour');
+ }
+ $date->setTimezone($timezone);
+
+ $date->setTime($date->format('H'), $invert ? 59 : 0);
+ return $this;
+ }
+
+ $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts);
+ $hours = array();
+ foreach ($parts as $part) {
+ $hours = array_merge($hours, $this->getRangeForExpression($part, 23));
+ }
+
+ $current_hour = $date->format('H');
+ $position = $invert ? count($hours) - 1 : 0;
+ if (count($hours) > 1) {
+ for ($i = 0; $i < count($hours) - 1; $i++) {
+ if ((!$invert && $current_hour >= $hours[$i] && $current_hour < $hours[$i + 1]) ||
+ ($invert && $current_hour > $hours[$i] && $current_hour <= $hours[$i + 1])) {
+ $position = $invert ? $i : $i + 1;
+ break;
+ }
+ }
+ }
+
+ $hour = $hours[$position];
+ if ((!$invert && $date->format('H') >= $hour) || ($invert && $date->format('H') <= $hour)) {
+ $date->modify(($invert ? '-' : '+') . '1 day');
+ $date->setTime($invert ? 23 : 0, $invert ? 59 : 0);
+ }
+ else {
+ $date->setTime($hour, $invert ? 59 : 0);
}
- $date->setTimezone($timezone);
return $this;
}
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/MinutesField.php b/application/vendor/mtdowling/cron-expression/src/Cron/MinutesField.php
index cfa2b09..d8432b5 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/MinutesField.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/MinutesField.php
@@ -2,22 +2,54 @@
namespace Cron;
+use DateTime;
+
+
/**
* Minutes field. Allows: * , / -
*/
class MinutesField extends AbstractField
{
- public function isSatisfiedBy(\DateTime $date, $value)
+ public function isSatisfiedBy(DateTime $date, $value)
{
return $this->isSatisfied($date->format('i'), $value);
}
- public function increment(\DateTime $date, $invert = false)
+ public function increment(DateTime $date, $invert = false, $parts = null)
{
- if ($invert) {
- $date->modify('-1 minute');
- } else {
- $date->modify('+1 minute');
+ if (is_null($parts)) {
+ if ($invert) {
+ $date->modify('-1 minute');
+ } else {
+ $date->modify('+1 minute');
+ }
+ return $this;
+ }
+
+ $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts);
+ $minutes = array();
+ foreach ($parts as $part) {
+ $minutes = array_merge($minutes, $this->getRangeForExpression($part, 59));
+ }
+
+ $current_minute = $date->format('i');
+ $position = $invert ? count($minutes) - 1 : 0;
+ if (count($minutes) > 1) {
+ for ($i = 0; $i < count($minutes) - 1; $i++) {
+ if ((!$invert && $current_minute >= $minutes[$i] && $current_minute < $minutes[$i + 1]) ||
+ ($invert && $current_minute > $minutes[$i] && $current_minute <= $minutes[$i + 1])) {
+ $position = $invert ? $i : $i + 1;
+ break;
+ }
+ }
+ }
+
+ if ((!$invert && $current_minute >= $minutes[$position]) || ($invert && $current_minute <= $minutes[$position])) {
+ $date->modify(($invert ? '-' : '+') . '1 hour');
+ $date->setTime($date->format('H'), $invert ? 59 : 0);
+ }
+ else {
+ $date->setTime($date->format('H'), $minutes[$position]);
}
return $this;
diff --git a/application/vendor/mtdowling/cron-expression/src/Cron/YearField.php b/application/vendor/mtdowling/cron-expression/src/Cron/YearField.php
index b526dde..db244fb 100644
--- a/application/vendor/mtdowling/cron-expression/src/Cron/YearField.php
+++ b/application/vendor/mtdowling/cron-expression/src/Cron/YearField.php
@@ -2,17 +2,20 @@
namespace Cron;
+use DateTime;
+
+
/**
* Year field. Allows: * , / -
*/
class YearField extends AbstractField
{
- public function isSatisfiedBy(\DateTime $date, $value)
+ public function isSatisfiedBy(DateTime $date, $value)
{
return $this->isSatisfied($date->format('Y'), $value);
}
- public function increment(\DateTime $date, $invert = false)
+ public function increment(DateTime $date, $invert = false)
{
if ($invert) {
$date->modify('-1 year');
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/AbstractFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/AbstractFieldTest.php
index 5272106..a1d653b 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/AbstractFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/AbstractFieldTest.php
@@ -3,11 +3,12 @@
namespace Cron\Tests;
use Cron\DayOfWeekField;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class AbstractFieldTest extends \PHPUnit_Framework_TestCase
+class AbstractFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\AbstractField::isRange
@@ -26,7 +27,6 @@ public function testTestsIfIncrementsOfRanges()
{
$f = new DayOfWeekField();
$this->assertFalse($f->isIncrementsOfRanges('1-2'));
- $this->assertFalse($f->isIncrementsOfRanges('1-2'));
$this->assertTrue($f->isIncrementsOfRanges('1/2'));
$this->assertTrue($f->isIncrementsOfRanges('*/2'));
$this->assertTrue($f->isIncrementsOfRanges('3-12/2'));
@@ -38,11 +38,11 @@ public function testTestsIfIncrementsOfRanges()
public function testTestsIfInRange()
{
$f = new DayOfWeekField();
- $this->assertTrue($f->isInRange(1, '1-2'));
- $this->assertTrue($f->isInRange(2, '1-2'));
- $this->assertTrue($f->isInRange(5, '4-12'));
- $this->assertFalse($f->isInRange(3, '4-12'));
- $this->assertFalse($f->isInRange(13, '4-12'));
+ $this->assertTrue($f->isInRange('1', '1-2'));
+ $this->assertTrue($f->isInRange('2', '1-2'));
+ $this->assertTrue($f->isInRange('5', '4-12'));
+ $this->assertFalse($f->isInRange('3', '4-12'));
+ $this->assertFalse($f->isInRange('13', '4-12'));
}
/**
@@ -51,20 +51,22 @@ public function testTestsIfInRange()
public function testTestsIfInIncrementsOfRanges()
{
$f = new DayOfWeekField();
- $this->assertTrue($f->isInIncrementsOfRanges(3, '3-59/2'));
- $this->assertTrue($f->isInIncrementsOfRanges(13, '3-59/2'));
- $this->assertTrue($f->isInIncrementsOfRanges(15, '3-59/2'));
- $this->assertTrue($f->isInIncrementsOfRanges(14, '*/2'));
- $this->assertFalse($f->isInIncrementsOfRanges(2, '3-59/13'));
- $this->assertFalse($f->isInIncrementsOfRanges(14, '*/13'));
- $this->assertFalse($f->isInIncrementsOfRanges(14, '3-59/2'));
- $this->assertFalse($f->isInIncrementsOfRanges(3, '2-59'));
- $this->assertFalse($f->isInIncrementsOfRanges(3, '2'));
- $this->assertFalse($f->isInIncrementsOfRanges(3, '*'));
+ $this->assertTrue($f->isInIncrementsOfRanges('3', '3-59/2'));
+ $this->assertTrue($f->isInIncrementsOfRanges('13', '3-59/2'));
+ $this->assertTrue($f->isInIncrementsOfRanges('15', '3-59/2'));
+ $this->assertTrue($f->isInIncrementsOfRanges('14', '*/2'));
+ $this->assertFalse($f->isInIncrementsOfRanges('2', '3-59/13'));
+ $this->assertFalse($f->isInIncrementsOfRanges('14', '*/13'));
+ $this->assertFalse($f->isInIncrementsOfRanges('14', '3-59/2'));
+ $this->assertFalse($f->isInIncrementsOfRanges('3', '2-59'));
+ $this->assertFalse($f->isInIncrementsOfRanges('3', '2'));
+ $this->assertFalse($f->isInIncrementsOfRanges('3', '*'));
+ $this->assertFalse($f->isInIncrementsOfRanges('0', '*/0'));
+ $this->assertFalse($f->isInIncrementsOfRanges('1', '*/0'));
- $this->assertTrue($f->isInIncrementsOfRanges(4, '4/10'));
- $this->assertTrue($f->isInIncrementsOfRanges(14, '4/10'));
- $this->assertTrue($f->isInIncrementsOfRanges(34, '4/10'));
+ $this->assertTrue($f->isInIncrementsOfRanges('4', '4/10'));
+ $this->assertTrue($f->isInIncrementsOfRanges('14', '4/10'));
+ $this->assertTrue($f->isInIncrementsOfRanges('34', '4/10'));
}
/**
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/CronExpressionTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/CronExpressionTest.php
index 013b701..f6fedb9 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/CronExpressionTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/CronExpressionTest.php
@@ -4,12 +4,14 @@
use Cron\CronExpression;
use DateTime;
+use DateTimeZone;
use InvalidArgumentException;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class CronExpressionTest extends \PHPUnit_Framework_TestCase
+class CronExpressionTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\CronExpression::factory
@@ -222,9 +224,9 @@ public function testIsDueHandlesDifferentTimezones()
{
$cron = CronExpression::factory('0 15 * * 3'); //Wednesday at 15:00
$date = '2014-01-01 15:00'; //Wednesday
- $utc = new \DateTimeZone('UTC');
- $amsterdam = new \DateTimeZone('Europe/Amsterdam');
- $tokyo = new \DateTimeZone('Asia/Tokyo');
+ $utc = new DateTimeZone('UTC');
+ $amsterdam = new DateTimeZone('Europe/Amsterdam');
+ $tokyo = new DateTimeZone('Asia/Tokyo');
date_default_timezone_set('UTC');
$this->assertTrue($cron->isDue(new DateTime($date, $utc)));
@@ -277,6 +279,27 @@ public function testProvidesMultipleRunDates()
), $cron->getMultipleRunDates(4, '2008-11-09 00:00:00', false, true));
}
+ /**
+ * @covers Cron\CronExpression::getMultipleRunDates
+ * @covers Cron\CronExpression::setMaxIterationCount
+ */
+ public function testProvidesMultipleRunDatesForTheFarFuture() {
+ // Fails with the default 1000 iteration limit
+ $cron = CronExpression::factory('0 0 12 1 * */2');
+ $cron->setMaxIterationCount(2000);
+ $this->assertEquals(array(
+ new DateTime('2016-01-12 00:00:00'),
+ new DateTime('2018-01-12 00:00:00'),
+ new DateTime('2020-01-12 00:00:00'),
+ new DateTime('2022-01-12 00:00:00'),
+ new DateTime('2024-01-12 00:00:00'),
+ new DateTime('2026-01-12 00:00:00'),
+ new DateTime('2028-01-12 00:00:00'),
+ new DateTime('2030-01-12 00:00:00'),
+ new DateTime('2032-01-12 00:00:00'),
+ ), $cron->getMultipleRunDates(9, '2015-04-28 00:00:00', false, true));
+ }
+
/**
* @covers Cron\CronExpression
*/
@@ -368,9 +391,24 @@ public function testIssue20() {
public function testKeepOriginalTime()
{
$now = new \DateTime;
- $strNow = $now->format(\DateTime::ISO8601);
+ $strNow = $now->format(DateTime::ISO8601);
$cron = CronExpression::factory('0 0 * * *');
$cron->getPreviousRunDate($now);
- $this->assertEquals($strNow, $now->format(\DateTime::ISO8601));
+ $this->assertEquals($strNow, $now->format(DateTime::ISO8601));
+ }
+
+ /**
+ * @covers Cron\CronExpression::__construct
+ * @covers Cron\CronExpression::factory
+ * @covers Cron\CronExpression::isValidExpression
+ * @covers Cron\CronExpression::setExpression
+ * @covers Cron\CronExpression::setPart
+ */
+ public function testValidationWorks()
+ {
+ // Invalid. Only four values
+ $this->assertFalse(CronExpression::isValidExpression('* * * 1'));
+ // Valid
+ $this->assertTrue(CronExpression::isValidExpression('* * * * 1'));
}
}
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfMonthFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfMonthFieldTest.php
index 94afbb0..eff0455 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfMonthFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfMonthFieldTest.php
@@ -3,23 +3,22 @@
namespace Cron\Tests;
use Cron\DayOfMonthField;
-
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class DayOfMonthFieldTest extends \PHPUnit_Framework_TestCase
+class DayOfMonthFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\DayOfMonthField::validate
*/
- public function testValdatesField()
+ public function testValidatesField()
{
$f = new DayOfMonthField();
$this->assertTrue($f->validate('1'));
$this->assertTrue($f->validate('*'));
- $this->assertTrue($f->validate('*/3,1,1-12'));
$this->assertTrue($f->validate('5W,L'));
$this->assertFalse($f->validate('1.'));
}
@@ -47,4 +46,16 @@ public function testIncrementsDate()
$f->increment($d, true);
$this->assertEquals('2011-03-14 23:59:00', $d->format('Y-m-d H:i:s'));
}
+
+ /**
+ * Day of the month cannot accept a 0 value, it must be between 1 and 31
+ * See Github issue #120
+ *
+ * @since 2017-01-22
+ */
+ public function testDoesNotAccept0Date()
+ {
+ $f = new DayOfMonthField();
+ $this->assertFalse($f->validate(0));
+ }
}
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfWeekFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfWeekFieldTest.php
index 703a517..182d5e9 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfWeekFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/DayOfWeekFieldTest.php
@@ -4,11 +4,12 @@
use Cron\DayOfWeekField;
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class DayOfWeekFieldTest extends \PHPUnit_Framework_TestCase
+class DayOfWeekFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\DayOfWeekField::validate
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/FieldFactoryTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/FieldFactoryTest.php
index ec087b1..f34cc9b 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/FieldFactoryTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/FieldFactoryTest.php
@@ -3,11 +3,12 @@
namespace Cron\Tests;
use Cron\FieldFactory;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class FieldFactoryTest extends \PHPUnit_Framework_TestCase
+class FieldFactoryTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\FieldFactory::getField
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/HoursFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/HoursFieldTest.php
index 48bd135..d2d8a22 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/HoursFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/HoursFieldTest.php
@@ -4,16 +4,17 @@
use Cron\HoursField;
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class HoursFieldTest extends \PHPUnit_Framework_TestCase
+class HoursFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\HoursField::validate
*/
- public function testValdatesField()
+ public function testValidatesField()
{
$f = new HoursField();
$this->assertTrue($f->validate('1'));
@@ -35,4 +36,40 @@ public function testIncrementsDate()
$f->increment($d, true);
$this->assertEquals('2011-03-15 10:59:00', $d->format('Y-m-d H:i:s'));
}
+
+ /**
+ * @covers Cron\HoursField::increment
+ */
+ public function testIncrementsDateWithThirtyMinuteOffsetTimezone()
+ {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('America/St_Johns');
+ $d = new DateTime('2011-03-15 11:15:00');
+ $f = new HoursField();
+ $f->increment($d);
+ $this->assertEquals('2011-03-15 12:00:00', $d->format('Y-m-d H:i:s'));
+
+ $d->setTime(11, 15, 0);
+ $f->increment($d, true);
+ $this->assertEquals('2011-03-15 10:59:00', $d->format('Y-m-d H:i:s'));
+ date_default_timezone_set($tz);
+ }
+
+ /**
+ * @covers Cron\HoursField::increment
+ */
+ public function testIncrementDateWithFifteenMinuteOffsetTimezone()
+ {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('Asia/Kathmandu');
+ $d = new DateTime('2011-03-15 11:15:00');
+ $f = new HoursField();
+ $f->increment($d);
+ $this->assertEquals('2011-03-15 12:00:00', $d->format('Y-m-d H:i:s'));
+
+ $d->setTime(11, 15, 0);
+ $f->increment($d, true);
+ $this->assertEquals('2011-03-15 10:59:00', $d->format('Y-m-d H:i:s'));
+ date_default_timezone_set($tz);
+ }
}
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/MinutesFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/MinutesFieldTest.php
index 82ce966..af3fef7 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/MinutesFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/MinutesFieldTest.php
@@ -4,16 +4,17 @@
use Cron\MinutesField;
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class MinutesFieldTest extends \PHPUnit_Framework_TestCase
+class MinutesFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\MinutesField::validate
*/
- public function testValdatesField()
+ public function testValidatesField()
{
$f = new MinutesField();
$this->assertTrue($f->validate('1'));
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/MonthFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/MonthFieldTest.php
index 82878f8..2d9b0ad 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/MonthFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/MonthFieldTest.php
@@ -4,16 +4,17 @@
use Cron\MonthField;
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class MonthFieldTest extends \PHPUnit_Framework_TestCase
+class MonthFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\MonthField::validate
*/
- public function testValdatesField()
+ public function testValidatesField()
{
$f = new MonthField();
$this->assertTrue($f->validate('12'));
@@ -37,6 +38,25 @@ public function testIncrementsDate()
$this->assertEquals('2011-02-28 23:59:00', $d->format('Y-m-d H:i:s'));
}
+ /**
+ * @covers Cron\MonthField::increment
+ */
+ public function testIncrementsDateWithThirtyMinuteTimezone()
+ {
+ $tz = date_default_timezone_get();
+ date_default_timezone_set('America/St_Johns');
+ $d = new DateTime('2011-03-31 11:59:59');
+ $f = new MonthField();
+ $f->increment($d);
+ $this->assertEquals('2011-04-01 00:00:00', $d->format('Y-m-d H:i:s'));
+
+ $d = new DateTime('2011-03-15 11:15:00');
+ $f->increment($d, true);
+ $this->assertEquals('2011-02-28 23:59:00', $d->format('Y-m-d H:i:s'));
+ date_default_timezone_set($tz);
+ }
+
+
/**
* @covers Cron\MonthField::increment
*/
diff --git a/application/vendor/mtdowling/cron-expression/tests/Cron/YearFieldTest.php b/application/vendor/mtdowling/cron-expression/tests/Cron/YearFieldTest.php
index e7bcacb..b5059ec 100644
--- a/application/vendor/mtdowling/cron-expression/tests/Cron/YearFieldTest.php
+++ b/application/vendor/mtdowling/cron-expression/tests/Cron/YearFieldTest.php
@@ -4,16 +4,17 @@
use Cron\YearField;
use DateTime;
+use PHPUnit_Framework_TestCase;
/**
* @author Michael Dowling
*/
-class YearFieldTest extends \PHPUnit_Framework_TestCase
+class YearFieldTest extends PHPUnit_Framework_TestCase
{
/**
* @covers Cron\YearField::validate
*/
- public function testValdatesField()
+ public function testValidatesField()
{
$f = new YearField();
$this->assertTrue($f->validate('2011'));
diff --git a/application/vendor/nesbot/carbon/bin/upgrade-carbon b/application/vendor/nesbot/carbon/bin/upgrade-carbon
new file mode 100644
index 0000000..49c4c9a
--- /dev/null
+++ b/application/vendor/nesbot/carbon/bin/upgrade-carbon
@@ -0,0 +1,34 @@
+#!/usr/bin/env php
+=5.3.9",
+ "kylekatarnls/update-helper": "^1.1",
+ "symfony/translation": "~2.6 || ~3.0 || ~4.0"
+ },
+ "require-dev": {
+ "composer/composer": "^1.2",
+ "friendsofphp/php-cs-fixer": "~2",
+ "phpunit/phpunit": "^4.8.35 || ^5.7"
+ },
+ "autoload": {
+ "psr-4": {
+ "": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Tests\\": "tests/"
+ }
+ },
+ "config": {
+ "sort-packages": true
+ },
+ "scripts": {
+ "test": [
+ "@phpunit",
+ "@phpcs"
+ ],
+ "phpunit": "phpunit --verbose --coverage-clover=coverage.xml",
+ "phpcs": "php-cs-fixer fix -v --diff --dry-run",
+ "phpstan": "phpstan analyse --configuration phpstan.neon --level 3 src tests",
+ "post-autoload-dump": [
+ "UpdateHelper\\UpdateHelper::check"
+ ],
+ "upgrade-carbon": [
+ "Carbon\\Upgrade::upgrade"
+ ]
+ },
+ "extra": {
+ "update-helper": "Carbon\\Upgrade",
+ "laravel": {
+ "providers": [
+ "Carbon\\Laravel\\ServiceProvider"
+ ]
+ }
}
- ],
- "require": {
- "php": ">=5.3.0",
- "symfony/translation": "~2.6|~3.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0|~5.0"
- },
- "autoload": {
- "psr-4": {
- "Carbon\\": "src/Carbon/"
- }
- },
- "autoload-dev": {
- "psr-4": {
- "Tests\\": "tests/"
- }
- }
}
diff --git a/application/vendor/nesbot/carbon/readme.md b/application/vendor/nesbot/carbon/readme.md
index 545bed3..5e9d1cc 100644
--- a/application/vendor/nesbot/carbon/readme.md
+++ b/application/vendor/nesbot/carbon/readme.md
@@ -4,15 +4,20 @@
[![Total Downloads](https://poser.pugx.org/nesbot/carbon/downloads.png)](https://packagist.org/packages/nesbot/carbon)
[![Build Status](https://travis-ci.org/briannesbitt/Carbon.svg?branch=master)](https://travis-ci.org/briannesbitt/Carbon)
[![StyleCI](https://styleci.io/repos/5724990/shield?style=flat)](https://styleci.io/repos/5724990)
+[![codecov.io](https://codecov.io/github/briannesbitt/Carbon/coverage.svg?branch=master)](https://codecov.io/github/briannesbitt/Carbon?branch=master)
+[![PHP-Eye](https://php-eye.com/badge/nesbot/carbon/tested.svg?style=flat)](https://php-eye.com/package/nesbot/carbon)
+[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)
A simple PHP API extension for DateTime. [http://carbon.nesbot.com](http://carbon.nesbot.com)
```php
+use Carbon\Carbon;
+
printf("Right now is %s", Carbon::now()->toDateTimeString());
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
$tomorrow = Carbon::now()->addDay();
$lastWeek = Carbon::now()->subWeek();
-$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4);
+$nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4);
$officialDate = Carbon::now()->toRfc2822String();
@@ -20,13 +25,13 @@ $howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
-$worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT');
+$internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');
-// Don't really want to die so mock now
+// Don't really want this to happen so mock now
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
// comparisons are always done in UTC
-if (Carbon::now()->gte($worldWillEnd)) {
+if (Carbon::now()->gte($internetWillBlowUpOn)) {
die();
}
@@ -55,7 +60,7 @@ $ composer require nesbot/carbon
```json
{
"require": {
- "nesbot/carbon": "~1.14"
+ "nesbot/carbon": "~1.21"
}
}
```
@@ -70,6 +75,7 @@ printf("Now: %s", Carbon::now());
```
+
### Without Composer
Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php) from the repo and save the file into your project path somewhere.
@@ -82,3 +88,7 @@ use Carbon\Carbon;
printf("Now: %s", Carbon::now());
```
+
+## Docs
+
+[http://carbon.nesbot.com/docs](http://carbon.nesbot.com/docs)
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Carbon.php b/application/vendor/nesbot/carbon/src/Carbon/Carbon.php
index 2d27616..7b8a5d9 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Carbon.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Carbon.php
@@ -11,14 +11,16 @@
namespace Carbon;
+use Carbon\Exceptions\InvalidDateException;
use Closure;
+use DateInterval;
+use DatePeriod;
use DateTime;
+use DateTimeInterface;
use DateTimeZone;
-use DatePeriod;
use InvalidArgumentException;
-use Symfony\Component\Translation\Translator;
+use JsonSerializable;
use Symfony\Component\Translation\TranslatorInterface;
-use Symfony\Component\Translation\Loader\ArrayLoader;
/**
* A simple API extension for DateTime
@@ -31,28 +33,47 @@
* @property int $minute
* @property int $second
* @property int $timestamp seconds since the Unix Epoch
- * @property DateTimeZone $timezone the current timezone
- * @property DateTimeZone $tz alias of timezone
- * @property-read integer $micro
- * @property-read integer $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
- * @property-read integer $dayOfYear 0 through 365
- * @property-read integer $weekOfMonth 1 through 5
- * @property-read integer $weekOfYear ISO-8601 week number of year, weeks starting on Monday
- * @property-read integer $daysInMonth number of days in the given month
- * @property-read integer $age does a diffInYears() with default parameters
- * @property-read integer $quarter the quarter of this instance, 1 - 4
- * @property-read integer $offset the timezone offset in seconds from UTC
- * @property-read integer $offsetHours the timezone offset in hours from UTC
- * @property-read boolean $dst daylight savings time indicator, true if DST, false otherwise
- * @property-read boolean $local checks if the timezone is local, true if local, false otherwise
- * @property-read boolean $utc checks if the timezone is UTC, true if UTC, false otherwise
- * @property-read string $timezoneName
- * @property-read string $tzName
+ * @property \DateTimeZone $timezone the current timezone
+ * @property \DateTimeZone $tz alias of timezone
+ * @property-read int $micro
+ * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday)
+ * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday)
+ * @property-read int $dayOfYear 0 through 365
+ * @property-read int $weekOfMonth 1 through 5
+ * @property-read int $weekNumberInMonth 1 through 5
+ * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
+ * @property-read int $daysInMonth number of days in the given month
+ * @property-read int $age does a diffInYears() with default parameters
+ * @property-read int $quarter the quarter of this instance, 1 - 4
+ * @property-read int $offset the timezone offset in seconds from UTC
+ * @property-read int $offsetHours the timezone offset in hours from UTC
+ * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
+ * @property-read bool $local checks if the timezone is local, true if local, false otherwise
+ * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
+ * @property-read string $timezoneName
+ * @property-read string $tzName
+ * @property-read string $englishDayOfWeek the day of week in English
+ * @property-read string $shortEnglishDayOfWeek the abbreviated day of week in English
+ * @property-read string $englishMonth the day of week in English
+ * @property-read string $shortEnglishMonth the abbreviated day of week in English
+ * @property-read string $localeDayOfWeek the day of week in current locale LC_TIME
+ * @property-read string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME
+ * @property-read string $localeMonth the month in current locale LC_TIME
+ * @property-read string $shortLocaleMonth the abbreviated month in current locale LC_TIME
*/
-class Carbon extends DateTime
+class Carbon extends DateTime implements JsonSerializable
{
+ const NO_ZERO_DIFF = 01;
+ const JUST_NOW = 02;
+ const ONE_DAY_WORDS = 04;
+ const TWO_DAY_WORDS = 010;
+
+ // Substitutes for Carbon 2 modes
+ const DIFF_RELATIVE_TO_NOW = 'relative-to-now';
+ const DIFF_RELATIVE_TO_OTHER = 'relative-to-other';
+
/**
- * The day constants
+ * The day constants.
*/
const SUNDAY = 0;
const MONDAY = 1;
@@ -78,34 +99,28 @@ class Carbon extends DateTime
);
/**
- * Terms used to detect if a time passed is a relative date for testing purposes
- *
- * @var array
- */
- protected static $relativeKeywords = array(
- 'this',
- 'next',
- 'last',
- 'tomorrow',
- 'yesterday',
- '+',
- '-',
- 'first',
- 'last',
- 'ago',
- );
-
- /**
- * Number of X in Y
+ * Number of X in Y.
*/
+ const YEARS_PER_MILLENNIUM = 1000;
const YEARS_PER_CENTURY = 100;
const YEARS_PER_DECADE = 10;
const MONTHS_PER_YEAR = 12;
+ const MONTHS_PER_QUARTER = 3;
const WEEKS_PER_YEAR = 52;
+ const WEEKS_PER_MONTH = 4;
const DAYS_PER_WEEK = 7;
const HOURS_PER_DAY = 24;
const MINUTES_PER_HOUR = 60;
const SECONDS_PER_MINUTE = 60;
+ const MICROSECONDS_PER_MILLISECOND = 1000;
+ const MICROSECONDS_PER_SECOND = 1000000;
+
+ /**
+ * RFC7231 DateTime format.
+ *
+ * @var string
+ */
+ const RFC7231_FORMAT = 'D, d M Y H:i:s \G\M\T';
/**
* Default format to use for __toString method when type juggling occurs.
@@ -114,6 +129,20 @@ class Carbon extends DateTime
*/
const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s';
+ /**
+ * Format for converting mocked time, includes microseconds.
+ *
+ * @var string
+ */
+ const MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u';
+
+ /**
+ * Customizable PHP_INT_SIZE override.
+ *
+ * @var int
+ */
+ public static $PHPIntSize = PHP_INT_SIZE;
+
/**
* Format to use for __toString method when type juggling occurs.
*
@@ -122,48 +151,308 @@ class Carbon extends DateTime
protected static $toStringFormat = self::DEFAULT_TO_STRING_FORMAT;
/**
- * First day of week
+ * First day of week.
*
* @var int
*/
protected static $weekStartsAt = self::MONDAY;
/**
- * Last day of week
+ * Last day of week.
*
* @var int
*/
protected static $weekEndsAt = self::SUNDAY;
/**
- * Days of weekend
+ * Days of weekend.
+ *
+ * @var array
+ */
+ protected static $weekendDays = array(
+ self::SATURDAY,
+ self::SUNDAY,
+ );
+
+ /**
+ * Midday/noon hour.
+ *
+ * @var int
+ */
+ protected static $midDayAt = 12;
+
+ /**
+ * Format regex patterns.
*
* @var array
*/
- protected static $weekendDays = array(self::SATURDAY, self::SUNDAY);
+ protected static $regexFormats = array(
+ 'd' => '(3[01]|[12][0-9]|0[1-9])',
+ 'D' => '([a-zA-Z]{3})',
+ 'j' => '([123][0-9]|[1-9])',
+ 'l' => '([a-zA-Z]{2,})',
+ 'N' => '([1-7])',
+ 'S' => '([a-zA-Z]{2})',
+ 'w' => '([0-6])',
+ 'z' => '(36[0-5]|3[0-5][0-9]|[12][0-9]{2}|[1-9]?[0-9])',
+ 'W' => '(5[012]|[1-4][0-9]|[1-9])',
+ 'F' => '([a-zA-Z]{2,})',
+ 'm' => '(1[012]|0[1-9])',
+ 'M' => '([a-zA-Z]{3})',
+ 'n' => '(1[012]|[1-9])',
+ 't' => '(2[89]|3[01])',
+ 'L' => '(0|1)',
+ 'o' => '([1-9][0-9]{0,4})',
+ 'Y' => '([1-9]?[0-9]{4})',
+ 'y' => '([0-9]{2})',
+ 'a' => '(am|pm)',
+ 'A' => '(AM|PM)',
+ 'B' => '([0-9]{3})',
+ 'g' => '(1[012]|[1-9])',
+ 'G' => '(2[0-3]|1?[0-9])',
+ 'h' => '(1[012]|0[1-9])',
+ 'H' => '(2[0-3]|[01][0-9])',
+ 'i' => '([0-5][0-9])',
+ 's' => '([0-5][0-9])',
+ 'u' => '([0-9]{1,6})',
+ 'v' => '([0-9]{1,3})',
+ 'e' => '([a-zA-Z]{1,5})|([a-zA-Z]*\/[a-zA-Z]*)',
+ 'I' => '(0|1)',
+ 'O' => '([\+\-](1[012]|0[0-9])[0134][05])',
+ 'P' => '([\+\-](1[012]|0[0-9]):[0134][05])',
+ 'T' => '([a-zA-Z]{1,5})',
+ 'Z' => '(-?[1-5]?[0-9]{1,4})',
+ 'U' => '([0-9]*)',
+
+ // The formats below are combinations of the above formats.
+ 'c' => '(([1-9]?[0-9]{4})\-(1[012]|0[1-9])\-(3[01]|[12][0-9]|0[1-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])[\+\-](1[012]|0[0-9]):([0134][05]))', // Y-m-dTH:i:sP
+ 'r' => '(([a-zA-Z]{3}), ([123][0-9]|[1-9]) ([a-zA-Z]{3}) ([1-9]?[0-9]{4}) (2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]) [\+\-](1[012]|0[0-9])([0134][05]))', // D, j M Y H:i:s O
+ );
/**
- * A test Carbon instance to be returned when now instances are created
+ * A test Carbon instance to be returned when now instances are created.
*
- * @var Carbon
+ * @var \Carbon\Carbon
*/
protected static $testNow;
/**
- * A translator to ... er ... translate stuff
+ * A translator to ... er ... translate stuff.
*
- * @var TranslatorInterface
+ * @var \Symfony\Component\Translation\TranslatorInterface
*/
protected static $translator;
/**
- * Creates a DateTimeZone from a string or a DateTimeZone
+ * The errors that can occur.
+ *
+ * @var array
+ */
+ protected static $lastErrors;
+
+ /**
+ * The custom Carbon JSON serializer.
*
- * @param DateTimeZone|string|null $object
+ * @var callable|null
+ */
+ protected static $serializer;
+
+ /**
+ * The registered string macros.
*
- * @throws InvalidArgumentException
+ * @var array
+ */
+ protected static $localMacros = array();
+
+ /**
+ * Will UTF8 encoding be used to print localized date/time ?
+ *
+ * @var bool
+ */
+ protected static $utf8 = false;
+
+ /**
+ * Add microseconds to now on PHP < 7.1 and 7.1.3. true by default.
+ *
+ * @var bool
+ */
+ protected static $microsecondsFallback = true;
+
+ /**
+ * Indicates if months should be calculated with overflow.
+ *
+ * @var bool
+ */
+ protected static $monthsOverflow = true;
+
+ /**
+ * Indicates if years should be calculated with overflow.
+ *
+ * @var bool
+ */
+ protected static $yearsOverflow = true;
+
+ /**
+ * Indicates if years are compared with month by default so isSameMonth and isSameQuarter have $ofSameYear set
+ * to true by default.
+ *
+ * @var bool
+ */
+ protected static $compareYearWithMonth = false;
+
+ /**
+ * Options for diffForHumans().
+ *
+ * @var int
+ */
+ protected static $humanDiffOptions = self::NO_ZERO_DIFF;
+
+ /**
+ * @param int $humanDiffOptions
+ */
+ public static function setHumanDiffOptions($humanDiffOptions)
+ {
+ static::$humanDiffOptions = $humanDiffOptions;
+ }
+
+ /**
+ * @param int $humanDiffOption
+ */
+ public static function enableHumanDiffOption($humanDiffOption)
+ {
+ static::$humanDiffOptions = static::getHumanDiffOptions() | $humanDiffOption;
+ }
+
+ /**
+ * @param int $humanDiffOption
+ */
+ public static function disableHumanDiffOption($humanDiffOption)
+ {
+ static::$humanDiffOptions = static::getHumanDiffOptions() & ~$humanDiffOption;
+ }
+
+ /**
+ * @return int
+ */
+ public static function getHumanDiffOptions()
+ {
+ return static::$humanDiffOptions;
+ }
+
+ /**
+ * Add microseconds to now on PHP < 7.1 and 7.1.3 if set to true,
+ * let microseconds to 0 on those PHP versions if false.
+ *
+ * @param bool $microsecondsFallback
+ */
+ public static function useMicrosecondsFallback($microsecondsFallback = true)
+ {
+ static::$microsecondsFallback = $microsecondsFallback;
+ }
+
+ /**
+ * Return true if microseconds fallback on PHP < 7.1 and 7.1.3 is
+ * enabled. false if disabled.
+ *
+ * @return bool
+ */
+ public static function isMicrosecondsFallbackEnabled()
+ {
+ return static::$microsecondsFallback;
+ }
+
+ /**
+ * Indicates if months should be calculated with overflow.
+ *
+ * @param bool $monthsOverflow
+ *
+ * @return void
+ */
+ public static function useMonthsOverflow($monthsOverflow = true)
+ {
+ static::$monthsOverflow = $monthsOverflow;
+ }
+
+ /**
+ * Reset the month overflow behavior.
+ *
+ * @return void
+ */
+ public static function resetMonthsOverflow()
+ {
+ static::$monthsOverflow = true;
+ }
+
+ /**
+ * Get the month overflow behavior.
+ *
+ * @return bool
+ */
+ public static function shouldOverflowMonths()
+ {
+ return static::$monthsOverflow;
+ }
+
+ /**
+ * Indicates if years should be calculated with overflow.
+ *
+ * @param bool $yearsOverflow
+ *
+ * @return void
+ */
+ public static function useYearsOverflow($yearsOverflow = true)
+ {
+ static::$yearsOverflow = $yearsOverflow;
+ }
+
+ /**
+ * Reset the month overflow behavior.
+ *
+ * @return void
+ */
+ public static function resetYearsOverflow()
+ {
+ static::$yearsOverflow = true;
+ }
+
+ /**
+ * Get the month overflow behavior.
+ *
+ * @return bool
+ */
+ public static function shouldOverflowYears()
+ {
+ return static::$yearsOverflow;
+ }
+
+ /**
+ * Get the month comparison default behavior.
+ *
+ * @return bool
+ */
+ public static function compareYearWithMonth($compareYearWithMonth = true)
+ {
+ static::$compareYearWithMonth = $compareYearWithMonth;
+ }
+
+ /**
+ * Get the month comparison default behavior.
+ *
+ * @return bool
+ */
+ public static function shouldCompareYearWithMonth()
+ {
+ return static::$compareYearWithMonth;
+ }
+
+ /**
+ * Creates a DateTimeZone from a string, DateTimeZone or integer offset.
+ *
+ * @param \DateTimeZone|string|int|null $object
*
- * @return DateTimeZone
+ * @throws \InvalidArgumentException
+ *
+ * @return \DateTimeZone
*/
protected static function safeCreateDateTimeZone($object)
{
@@ -176,13 +465,35 @@ protected static function safeCreateDateTimeZone($object)
return $object;
}
- $tz = @timezone_open((string) $object);
+ if (is_numeric($object)) {
+ $tzName = timezone_name_from_abbr(null, $object * 3600, true);
+
+ if ($tzName === false) {
+ throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')');
+ }
+
+ $object = $tzName;
+ }
+
+ $tz = @timezone_open($object = (string) $object);
+
+ if ($tz !== false) {
+ return $tz;
+ }
- if ($tz === false) {
- throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')');
+ // Work-around for a bug fixed in PHP 5.5.10 https://bugs.php.net/bug.php?id=45528
+ // See: https://stackoverflow.com/q/14068594/2646927
+ // @codeCoverageIgnoreStart
+ if (strpos($object, ':') !== false) {
+ try {
+ return static::createFromFormat('O', $object)->getTimezone();
+ } catch (InvalidArgumentException $e) {
+ //
+ }
}
+ // @codeCoverageIgnoreEnd
- return $tz;
+ throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')');
}
///////////////////////////////////////////////////////////////////
@@ -195,52 +506,86 @@ protected static function safeCreateDateTimeZone($object)
* Please see the testing aids section (specifically static::setTestNow())
* for more on the possibility of this constructor returning a test instance.
*
- * @param string|null $time
- * @param DateTimeZone|string|null $tz
+ * @param string|null $time
+ * @param \DateTimeZone|string|null $tz
*/
public function __construct($time = null, $tz = null)
{
// If the class has a test now set and we are trying to create a now()
// instance then override as required
- if (static::hasTestNow() && (empty($time) || $time === 'now' || static::hasRelativeKeywords($time))) {
+ $isNow = empty($time) || $time === 'now';
+ if (static::hasTestNow() && ($isNow || static::hasRelativeKeywords($time))) {
$testInstance = clone static::getTestNow();
- if (static::hasRelativeKeywords($time)) {
- $testInstance->modify($time);
- }
//shift the time according to the given time zone
- if ($tz !== null && $tz !== static::getTestNow()->tz) {
+ if ($tz !== null && $tz !== static::getTestNow()->getTimezone()) {
$testInstance->setTimezone($tz);
} else {
- $tz = $testInstance->tz;
+ $tz = $testInstance->getTimezone();
}
- $time = $testInstance->toDateTimeString();
+ if (static::hasRelativeKeywords($time)) {
+ $testInstance->modify($time);
+ }
+
+ $time = $testInstance->format(static::MOCK_DATETIME_FORMAT);
}
- parent::__construct($time, static::safeCreateDateTimeZone($tz));
+ $timezone = static::safeCreateDateTimeZone($tz);
+ // @codeCoverageIgnoreStart
+ if ($isNow && !isset($testInstance) && static::isMicrosecondsFallbackEnabled() && (
+ version_compare(PHP_VERSION, '7.1.0-dev', '<')
+ ||
+ version_compare(PHP_VERSION, '7.1.3-dev', '>=') && version_compare(PHP_VERSION, '7.1.4-dev', '<')
+ )
+ ) {
+ // Get microseconds from microtime() if "now" asked and PHP < 7.1 and PHP 7.1.3 if fallback enabled.
+ list($microTime, $timeStamp) = explode(' ', microtime());
+ $dateTime = new DateTime('now', $timezone);
+ $dateTime->setTimestamp($timeStamp); // Use the timestamp returned by microtime as now can happen in the next second
+ $time = $dateTime->format(static::DEFAULT_TO_STRING_FORMAT).substr($microTime, 1, 7);
+ }
+ // @codeCoverageIgnoreEnd
+
+ // Work-around for PHP bug https://bugs.php.net/bug.php?id=67127
+ if (strpos((string) .1, '.') === false) {
+ $locale = setlocale(LC_NUMERIC, '0');
+ setlocale(LC_NUMERIC, 'C');
+ }
+ parent::__construct($time, $timezone);
+ if (isset($locale)) {
+ setlocale(LC_NUMERIC, $locale);
+ }
+ static::setLastErrors(parent::getLastErrors());
}
/**
- * Create a Carbon instance from a DateTime one
+ * Create a Carbon instance from a DateTime one.
*
- * @param DateTime $dt
+ * @param \DateTime|\DateTimeInterface $date
*
* @return static
*/
- public static function instance(DateTime $dt)
+ public static function instance($date)
{
- return new static($dt->format('Y-m-d H:i:s.u'), $dt->getTimeZone());
+ if ($date instanceof static) {
+ return clone $date;
+ }
+
+ static::expectDateTime($date);
+
+ return new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone());
}
/**
- * Create a carbon instance from a string. This is an alias for the
- * constructor that allows better fluent syntax as it allows you to do
- * Carbon::parse('Monday next week')->fn() rather than
- * (new Carbon('Monday next week'))->fn()
+ * Create a carbon instance from a string.
+ *
+ * This is an alias for the constructor that allows better fluent syntax
+ * as it allows you to do Carbon::parse('Monday next week')->fn() rather
+ * than (new Carbon('Monday next week'))->fn().
*
- * @param string|null $time
- * @param DateTimeZone|string|null $tz
+ * @param string|null $time
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
@@ -250,9 +595,9 @@ public static function parse($time = null, $tz = null)
}
/**
- * Get a Carbon instance for the current date and time
+ * Get a Carbon instance for the current date and time.
*
- * @param DateTimeZone|string|null $tz
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
@@ -262,51 +607,51 @@ public static function now($tz = null)
}
/**
- * Create a Carbon instance for today
+ * Create a Carbon instance for today.
*
- * @param DateTimeZone|string|null $tz
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
public static function today($tz = null)
{
- return static::now($tz)->startOfDay();
+ return static::parse('today', $tz);
}
/**
- * Create a Carbon instance for tomorrow
+ * Create a Carbon instance for tomorrow.
*
- * @param DateTimeZone|string|null $tz
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
public static function tomorrow($tz = null)
{
- return static::today($tz)->addDay();
+ return static::parse('tomorrow', $tz);
}
/**
- * Create a Carbon instance for yesterday
+ * Create a Carbon instance for yesterday.
*
- * @param DateTimeZone|string|null $tz
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
public static function yesterday($tz = null)
{
- return static::today($tz)->subDay();
+ return static::parse('yesterday', $tz);
}
/**
* Create a Carbon instance for the greatest supported date.
*
- * @return Carbon
+ * @return static
*/
public static function maxValue()
{
- if (PHP_INT_SIZE === 4) {
- // 32 bit (and additionally Windows 64 bit)
- return static::createFromTimestamp(PHP_INT_MAX);
+ if (self::$PHPIntSize === 4) {
+ // 32 bit
+ return static::createFromTimestamp(PHP_INT_MAX); // @codeCoverageIgnore
}
// 64 bit
@@ -316,13 +661,13 @@ public static function maxValue()
/**
* Create a Carbon instance for the lowest supported date.
*
- * @return Carbon
+ * @return static
*/
public static function minValue()
{
- if (PHP_INT_SIZE === 4) {
- // 32 bit (and additionally Windows 64 bit)
- return static::createFromTimestamp(~PHP_INT_MAX);
+ if (self::$PHPIntSize === 4) {
+ // 32 bit
+ return static::createFromTimestamp(~PHP_INT_MAX); // @codeCoverageIgnore
}
// 64 bit
@@ -332,175 +677,457 @@ public static function minValue()
/**
* Create a new Carbon instance from a specific date and time.
*
- * If any of $year, $month or $day are set to null their now() values
- * will be used.
+ * If any of $year, $month or $day are set to null their now() values will
+ * be used.
+ *
+ * If $hour is null it will be set to its now() value and the default
+ * values for $minute and $second will be their now() values.
*
- * If $hour is null it will be set to its now() value and the default values
- * for $minute and $second will be their now() values.
* If $hour is not null then the default values for $minute and $second
* will be 0.
*
- * @param int|null $year
- * @param int|null $month
- * @param int|null $day
- * @param int|null $hour
- * @param int|null $minute
- * @param int|null $second
- * @param DateTimeZone|string|null $tz
+ * @param int|null $year
+ * @param int|null $month
+ * @param int|null $day
+ * @param int|null $hour
+ * @param int|null $minute
+ * @param int|null $second
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @throws \InvalidArgumentException
*
* @return static
*/
public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
{
- $year = $year === null ? date('Y') : $year;
- $month = $month === null ? date('n') : $month;
- $day = $day === null ? date('j') : $day;
+ $now = static::hasTestNow() ? static::getTestNow() : static::now($tz);
+
+ $defaults = array_combine(array(
+ 'year',
+ 'month',
+ 'day',
+ 'hour',
+ 'minute',
+ 'second',
+ ), explode('-', $now->format('Y-n-j-G-i-s')));
+
+ $year = $year === null ? $defaults['year'] : $year;
+ $month = $month === null ? $defaults['month'] : $month;
+ $day = $day === null ? $defaults['day'] : $day;
if ($hour === null) {
- $hour = date('G');
- $minute = $minute === null ? date('i') : $minute;
- $second = $second === null ? date('s') : $second;
+ $hour = $defaults['hour'];
+ $minute = $minute === null ? $defaults['minute'] : $minute;
+ $second = $second === null ? $defaults['second'] : $second;
} else {
$minute = $minute === null ? 0 : $minute;
$second = $second === null ? 0 : $second;
}
- return static::createFromFormat('Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz);
+ $fixYear = null;
+
+ if ($year < 0) {
+ $fixYear = $year;
+ $year = 0;
+ } elseif ($year > 9999) {
+ $fixYear = $year - 9999;
+ $year = 9999;
+ }
+
+ $instance = static::createFromFormat('!Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz);
+
+ if ($fixYear !== null) {
+ $instance->addYears($fixYear);
+ }
+
+ return $instance;
}
/**
- * Create a Carbon instance from just a date. The time portion is set to now.
+ * Create a new safe Carbon instance from a specific date and time.
*
- * @param int|null $year
- * @param int|null $month
- * @param int|null $day
- * @param DateTimeZone|string|null $tz
+ * If any of $year, $month or $day are set to null their now() values will
+ * be used.
*
- * @return static
- */
- public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
- {
- return static::create($year, $month, $day, null, null, null, $tz);
- }
-
- /**
- * Create a Carbon instance from just a time. The date portion is set to today.
+ * If $hour is null it will be set to its now() value and the default
+ * values for $minute and $second will be their now() values.
+ *
+ * If $hour is not null then the default values for $minute and $second
+ * will be 0.
+ *
+ * If one of the set values is not valid, an \InvalidArgumentException
+ * will be thrown.
*
- * @param int|null $hour
- * @param int|null $minute
- * @param int|null $second
- * @param DateTimeZone|string|null $tz
+ * @param int|null $year
+ * @param int|null $month
+ * @param int|null $day
+ * @param int|null $hour
+ * @param int|null $minute
+ * @param int|null $second
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @throws \Carbon\Exceptions\InvalidDateException|\InvalidArgumentException
*
* @return static
*/
- public static function createFromTime($hour = null, $minute = null, $second = null, $tz = null)
+ public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null)
{
- return static::create(null, null, null, $hour, $minute, $second, $tz);
+ $fields = array(
+ 'year' => array(0, 9999),
+ 'month' => array(0, 12),
+ 'day' => array(0, 31),
+ 'hour' => array(0, 24),
+ 'minute' => array(0, 59),
+ 'second' => array(0, 59),
+ );
+
+ foreach ($fields as $field => $range) {
+ if ($$field !== null && (!is_int($$field) || $$field < $range[0] || $$field > $range[1])) {
+ throw new InvalidDateException($field, $$field);
+ }
+ }
+
+ $instance = static::create($year, $month, $day, $hour, $minute, $second, $tz);
+
+ foreach (array_reverse($fields) as $field => $range) {
+ if ($$field !== null && (!is_int($$field) || $$field !== $instance->$field)) {
+ throw new InvalidDateException($field, $$field);
+ }
+ }
+
+ return $instance;
}
/**
- * Create a Carbon instance from a specific format
+ * Create a Carbon instance from just a date. The time portion is set to now.
*
- * @param string $format
- * @param string $time
- * @param DateTimeZone|string|null $tz
+ * @param int|null $year
+ * @param int|null $month
+ * @param int|null $day
+ * @param \DateTimeZone|string|null $tz
*
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
*
* @return static
*/
- public static function createFromFormat($format, $time, $tz = null)
+ public static function createFromDate($year = null, $month = null, $day = null, $tz = null)
{
- if ($tz !== null) {
- $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
- } else {
- $dt = parent::createFromFormat($format, $time);
- }
-
- if ($dt instanceof DateTime) {
- return static::instance($dt);
- }
-
- $errors = static::getLastErrors();
- throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors']));
+ return static::create($year, $month, $day, null, null, null, $tz);
}
/**
- * Create a Carbon instance from a timestamp
+ * Create a Carbon instance from just a date. The time portion is set to midnight.
*
- * @param int $timestamp
- * @param DateTimeZone|string|null $tz
+ * @param int|null $year
+ * @param int|null $month
+ * @param int|null $day
+ * @param \DateTimeZone|string|null $tz
*
* @return static
*/
- public static function createFromTimestamp($timestamp, $tz = null)
+ public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null)
{
- return static::now($tz)->setTimestamp($timestamp);
+ return static::create($year, $month, $day, 0, 0, 0, $tz);
}
/**
- * Create a Carbon instance from an UTC timestamp
+ * Create a Carbon instance from just a time. The date portion is set to today.
*
- * @param int $timestamp
+ * @param int|null $hour
+ * @param int|null $minute
+ * @param int|null $second
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @throws \InvalidArgumentException
*
* @return static
*/
- public static function createFromTimestampUTC($timestamp)
+ public static function createFromTime($hour = null, $minute = null, $second = null, $tz = null)
{
- return new static('@'.$timestamp);
+ return static::create(null, null, null, $hour, $minute, $second, $tz);
}
/**
- * Get a copy of the instance
+ * Create a Carbon instance from a time string. The date portion is set to today.
+ *
+ * @param string $time
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @throws \InvalidArgumentException
*
* @return static
*/
- public function copy()
+ public static function createFromTimeString($time, $tz = null)
{
- return static::instance($this);
+ return static::today($tz)->setTimeFromTimeString($time);
}
- ///////////////////////////////////////////////////////////////////
- ///////////////////////// GETTERS AND SETTERS /////////////////////
- ///////////////////////////////////////////////////////////////////
+ private static function createFromFormatAndTimezone($format, $time, $tz)
+ {
+ return $tz !== null
+ ? parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz))
+ : parent::createFromFormat($format, $time);
+ }
/**
- * Get a part of the Carbon object
+ * Create a Carbon instance from a specific format.
*
- * @param string $name
+ * @param string $format Datetime format
+ * @param string $time
+ * @param \DateTimeZone|string|null $tz
*
* @throws InvalidArgumentException
*
- * @return string|int|DateTimeZone
+ * @return static
*/
- public function __get($name)
+ public static function createFromFormat($format, $time, $tz = null)
{
+ // First attempt to create an instance, so that error messages are based on the unmodified format.
+ $date = self::createFromFormatAndTimezone($format, $time, $tz);
+ $lastErrors = parent::getLastErrors();
+
+ if (($mock = static::getTestNow()) && ($date instanceof DateTime || $date instanceof DateTimeInterface)) {
+ // Set timezone from mock if custom timezone was neither given directly nor as a part of format.
+ // First let's skip the part that will be ignored by the parser.
+ $nonEscaped = '(?getTimezone();
+ }
+
+ // Prepend mock datetime only if the format does not contain non escaped unix epoch reset flag.
+ if (!preg_match("/{$nonEscaped}[!|]/", $format)) {
+ $format = static::MOCK_DATETIME_FORMAT.' '.$format;
+ $time = $mock->format(static::MOCK_DATETIME_FORMAT).' '.$time;
+ }
+
+ // Regenerate date from the modified format to base result on the mocked instance instead of now.
+ $date = self::createFromFormatAndTimezone($format, $time, $tz);
+ }
+
+ if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
+ $instance = static::instance($date);
+ $instance::setLastErrors($lastErrors);
+
+ return $instance;
+ }
+
+ throw new InvalidArgumentException(implode(PHP_EOL, $lastErrors['errors']));
+ }
+
+ /**
+ * Set last errors.
+ *
+ * @param array $lastErrors
+ *
+ * @return void
+ */
+ private static function setLastErrors(array $lastErrors)
+ {
+ static::$lastErrors = $lastErrors;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getLastErrors()
+ {
+ return static::$lastErrors;
+ }
+
+ /**
+ * Create a Carbon instance from a timestamp.
+ *
+ * @param int $timestamp
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @return static
+ */
+ public static function createFromTimestamp($timestamp, $tz = null)
+ {
+ return static::today($tz)->setTimestamp($timestamp);
+ }
+
+ /**
+ * Create a Carbon instance from a timestamp in milliseconds.
+ *
+ * @param int $timestamp
+ * @param \DateTimeZone|string|null $tz
+ *
+ * @return static
+ */
+ public static function createFromTimestampMs($timestamp, $tz = null)
+ {
+ return static::createFromFormat('U.u', sprintf('%F', $timestamp / 1000))
+ ->setTimezone($tz);
+ }
+
+ /**
+ * Create a Carbon instance from an UTC timestamp.
+ *
+ * @param int $timestamp
+ *
+ * @return static
+ */
+ public static function createFromTimestampUTC($timestamp)
+ {
+ return new static('@'.$timestamp);
+ }
+
+ /**
+ * Make a Carbon instance from given variable if possible.
+ *
+ * Always return a new instance. Parse only strings and only these likely to be dates (skip intervals
+ * and recurrences). Throw an exception for invalid format, but otherwise return null.
+ *
+ * @param mixed $var
+ *
+ * @return static|null
+ */
+ public static function make($var)
+ {
+ if ($var instanceof DateTime || $var instanceof DateTimeInterface) {
+ return static::instance($var);
+ }
+
+ if (is_string($var)) {
+ $var = trim($var);
+ $first = substr($var, 0, 1);
+
+ if (is_string($var) && $first !== 'P' && $first !== 'R' && preg_match('/[a-z0-9]/i', $var)) {
+ return static::parse($var);
+ }
+ }
+ }
+
+ /**
+ * Get a copy of the instance.
+ *
+ * @return static
+ */
+ public function copy()
+ {
+ return clone $this;
+ }
+
+ /**
+ * Returns a present instance in the same timezone.
+ *
+ * @return static
+ */
+ public function nowWithSameTz()
+ {
+ return static::now($this->getTimezone());
+ }
+
+ /**
+ * Throws an exception if the given object is not a DateTime and does not implement DateTimeInterface
+ * and not in $other.
+ *
+ * @param mixed $date
+ * @param string|array $other
+ *
+ * @throws \InvalidArgumentException
+ */
+ protected static function expectDateTime($date, $other = array())
+ {
+ $message = 'Expected ';
+ foreach ((array) $other as $expect) {
+ $message .= "{$expect}, ";
+ }
+
+ if (!$date instanceof DateTime && !$date instanceof DateTimeInterface) {
+ throw new InvalidArgumentException(
+ $message.'DateTime or DateTimeInterface, '.
+ (is_object($date) ? get_class($date) : gettype($date)).' given'
+ );
+ }
+ }
+
+ /**
+ * Return the Carbon instance passed through, a now instance in the same timezone
+ * if null given or parse the input if string given.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ *
+ * @return static
+ */
+ protected function resolveCarbon($date = null)
+ {
+ if (!$date) {
+ return $this->nowWithSameTz();
+ }
+
+ if (is_string($date)) {
+ return static::parse($date, $this->getTimezone());
+ }
+
+ static::expectDateTime($date, array('null', 'string'));
+
+ return $date instanceof self ? $date : static::instance($date);
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ ///////////////////////// GETTERS AND SETTERS /////////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Get a part of the Carbon object
+ *
+ * @param string $name
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return string|int|bool|\DateTimeZone
+ */
+ public function __get($name)
+ {
+ static $formats = array(
+ 'year' => 'Y',
+ 'yearIso' => 'o',
+ 'month' => 'n',
+ 'day' => 'j',
+ 'hour' => 'G',
+ 'minute' => 'i',
+ 'second' => 's',
+ 'micro' => 'u',
+ 'dayOfWeek' => 'w',
+ 'dayOfWeekIso' => 'N',
+ 'dayOfYear' => 'z',
+ 'weekOfYear' => 'W',
+ 'daysInMonth' => 't',
+ 'timestamp' => 'U',
+ 'englishDayOfWeek' => 'l',
+ 'shortEnglishDayOfWeek' => 'D',
+ 'englishMonth' => 'F',
+ 'shortEnglishMonth' => 'M',
+ 'localeDayOfWeek' => '%A',
+ 'shortLocaleDayOfWeek' => '%a',
+ 'localeMonth' => '%B',
+ 'shortLocaleMonth' => '%b',
+ );
+
switch (true) {
- case array_key_exists($name, $formats = array(
- 'year' => 'Y',
- 'yearIso' => 'o',
- 'month' => 'n',
- 'day' => 'j',
- 'hour' => 'G',
- 'minute' => 'i',
- 'second' => 's',
- 'micro' => 'u',
- 'dayOfWeek' => 'w',
- 'dayOfYear' => 'z',
- 'weekOfYear' => 'W',
- 'daysInMonth' => 't',
- 'timestamp' => 'U',
- )):
- return (int) $this->format($formats[$name]);
+ case isset($formats[$name]):
+ $format = $formats[$name];
+ $method = substr($format, 0, 1) === '%' ? 'formatLocalized' : 'format';
+ $value = $this->$method($format);
+
+ return is_numeric($value) ? (int) $value : $value;
case $name === 'weekOfMonth':
return (int) ceil($this->day / static::DAYS_PER_WEEK);
+ case $name === 'weekNumberInMonth':
+ return (int) ceil(($this->day + $this->copy()->startOfMonth()->dayOfWeek - 1) / static::DAYS_PER_WEEK);
+
case $name === 'age':
- return (int) $this->diffInYears();
+ return $this->diffInYears();
case $name === 'quarter':
- return (int) ceil($this->month / 3);
+ return (int) ceil($this->month / static::MONTHS_PER_QUARTER);
case $name === 'offset':
return $this->getOffset();
@@ -512,10 +1139,10 @@ public function __get($name)
return $this->format('I') === '1';
case $name === 'local':
- return $this->offset === $this->copy()->setTimezone(date_default_timezone_get())->offset;
+ return $this->getOffset() === $this->copy()->setTimezone(date_default_timezone_get())->getOffset();
case $name === 'utc':
- return $this->offset === 0;
+ return $this->getOffset() === 0;
case $name === 'timezone' || $name === 'tz':
return $this->getTimezone();
@@ -549,36 +1176,25 @@ public function __isset($name)
/**
* Set a part of the Carbon object
*
- * @param string $name
- * @param string|int|DateTimeZone $value
+ * @param string $name
+ * @param string|int|\DateTimeZone $value
*
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
+ *
+ * @return void
*/
public function __set($name, $value)
{
switch ($name) {
case 'year':
- $this->setDate($value, $this->month, $this->day);
- break;
-
case 'month':
- $this->setDate($this->year, $value, $this->day);
- break;
-
case 'day':
- $this->setDate($this->year, $this->month, $value);
- break;
-
case 'hour':
- $this->setTime($value, $this->minute, $this->second);
- break;
-
case 'minute':
- $this->setTime($this->hour, $value, $this->second);
- break;
-
case 'second':
- $this->setTime($this->hour, $this->minute, $value);
+ list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-n-j-G-i-s'));
+ $$name = $value;
+ $this->setDateTime($year, $month, $day, $hour, $minute, $second);
break;
case 'timestamp':
@@ -679,6 +1295,26 @@ public function second($value)
return $this;
}
+ /**
+ * Sets the current date of the DateTime object to a different date.
+ * Calls modify as a workaround for a php bug
+ *
+ * @param int $year
+ * @param int $month
+ * @param int $day
+ *
+ * @return static
+ *
+ * @see https://github.com/briannesbitt/Carbon/issues/539
+ * @see https://bugs.php.net/bug.php?id=63863
+ */
+ public function setDate($year, $month, $day)
+ {
+ $this->modify('+0 day');
+
+ return parent::setDate($year, $month, $day);
+ }
+
/**
* Set the date and time all together
*
@@ -705,13 +1341,11 @@ public function setDateTime($year, $month, $day, $hour, $minute, $second = 0)
*/
public function setTimeFromTimeString($time)
{
- $time = explode(":", $time);
-
- $hour = $time[0];
- $minute = isset($time[1]) ? $time[1] : 0;
- $second = isset($time[2]) ? $time[2] : 0;
+ if (strpos($time, ':') === false) {
+ $time .= ':0';
+ }
- return $this->setTime($hour, $minute, $second);
+ return $this->modify($time);
}
/**
@@ -723,15 +1357,13 @@ public function setTimeFromTimeString($time)
*/
public function timestamp($value)
{
- $this->timestamp = $value;
-
- return $this;
+ return $this->setTimestamp($value);
}
/**
* Alias for setTimezone()
*
- * @param DateTimeZone|string $value
+ * @param \DateTimeZone|string $value
*
* @return static
*/
@@ -743,7 +1375,7 @@ public function timezone($value)
/**
* Alias for setTimezone()
*
- * @param DateTimeZone|string $value
+ * @param \DateTimeZone|string $value
*
* @return static
*/
@@ -755,17 +1387,62 @@ public function tz($value)
/**
* Set the instance's timezone from a string or object
*
- * @param DateTimeZone|string $value
+ * @param \DateTimeZone|string $value
*
* @return static
*/
public function setTimezone($value)
{
parent::setTimezone(static::safeCreateDateTimeZone($value));
+ // https://bugs.php.net/bug.php?id=72338
+ // just workaround on this bug
+ $this->getTimestamp();
+
+ return $this;
+ }
+
+ /**
+ * Set the year, month, and date for this instance to that of the passed instance.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface $date
+ *
+ * @return static
+ */
+ public function setDateFrom($date)
+ {
+ $date = static::instance($date);
+
+ $this->setDate($date->year, $date->month, $date->day);
+
+ return $this;
+ }
+
+ /**
+ * Set the hour, day, and time for this instance to that of the passed instance.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface $date
+ *
+ * @return static
+ */
+ public function setTimeFrom($date)
+ {
+ $date = static::instance($date);
+
+ $this->setTime($date->hour, $date->minute, $date->second);
return $this;
}
+ /**
+ * Get the days of the week
+ *
+ * @return array
+ */
+ public static function getDays()
+ {
+ return static::$days;
+ }
+
///////////////////////////////////////////////////////////////////
/////////////////////// WEEK SPECIAL DAYS /////////////////////////
///////////////////////////////////////////////////////////////////
@@ -783,10 +1460,18 @@ public static function getWeekStartsAt()
/**
* Set the first day of week
*
- * @param int
+ * @param int $day week start day
+ *
+ * @throws InvalidArgumentException
+ *
+ * @return void
*/
public static function setWeekStartsAt($day)
{
+ if ($day > static::SATURDAY || $day < static::SUNDAY) {
+ throw new InvalidArgumentException('Day of a week should be greater than or equal to 0 and less than or equal to 6.');
+ }
+
static::$weekStartsAt = $day;
}
@@ -801,12 +1486,20 @@ public static function getWeekEndsAt()
}
/**
- * Set the first day of week
+ * Set the last day of week
+ *
+ * @param int $day
+ *
+ * @throws InvalidArgumentException
*
- * @param int
+ * @return void
*/
public static function setWeekEndsAt($day)
{
+ if ($day > static::SATURDAY || $day < static::SUNDAY) {
+ throw new InvalidArgumentException('Day of a week should be greater than or equal to 0 and less than or equal to 6.');
+ }
+
static::$weekEndsAt = $day;
}
@@ -823,13 +1516,37 @@ public static function getWeekendDays()
/**
* Set weekend days
*
- * @param array
+ * @param array $days
+ *
+ * @return void
*/
public static function setWeekendDays($days)
{
static::$weekendDays = $days;
}
+ /**
+ * get midday/noon hour
+ *
+ * @return int
+ */
+ public static function getMidDayAt()
+ {
+ return static::$midDayAt;
+ }
+
+ /**
+ * Set midday/noon hour
+ *
+ * @param int $hour midday hour
+ *
+ * @return void
+ */
+ public static function setMidDayAt($hour)
+ {
+ static::$midDayAt = $hour;
+ }
+
///////////////////////////////////////////////////////////////////
///////////////////////// TESTING AIDS ////////////////////////////
///////////////////////////////////////////////////////////////////
@@ -841,6 +1558,7 @@ public static function setWeekendDays($days)
* - A call to the static now() method, ex. Carbon::now()
* - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null)
* - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now')
+ * - When a string containing the desired time is passed to Carbon::parse().
*
* Note the timezone parameter was left out of the examples above and
* has no affect as the mock value will be returned regardless of its value.
@@ -848,11 +1566,12 @@ public static function setWeekendDays($days)
* To clear the test instance call this method using the default
* parameter of null.
*
- * @param Carbon|null $testNow
+ * @param \Carbon\Carbon|null $testNow real or mock Carbon instance
+ * @param \Carbon\Carbon|string|null $testNow
*/
- public static function setTestNow(Carbon $testNow = null)
+ public static function setTestNow($testNow = null)
{
- static::$testNow = $testNow;
+ static::$testNow = is_string($testNow) ? static::parse($testNow) : $testNow;
}
/**
@@ -878,25 +1597,24 @@ public static function hasTestNow()
}
/**
- * Determine if there is a relative keyword in the time string, this is to
- * create dates relative to now for test instances. e.g.: next tuesday
+ * Determine if a time string will produce a relative date.
*
* @param string $time
*
- * @return bool true if there is a keyword, otherwise false
+ * @return bool true if time match a relative date, false if absolute or invalid time string
*/
public static function hasRelativeKeywords($time)
{
- // skip common format with a '-' in it
- if (preg_match('/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/', $time) !== 1) {
- foreach (static::$relativeKeywords as $keyword) {
- if (stripos($time, $keyword) !== false) {
- return true;
- }
- }
+ if (strtotime($time) === false) {
+ return false;
}
- return false;
+ $date1 = new DateTime('2000-01-01T00:00:00Z');
+ $date1->modify($time);
+ $date2 = new DateTime('2001-12-25T00:00:00Z');
+ $date2->modify($time);
+
+ return $date1 != $date2;
}
///////////////////////////////////////////////////////////////////
@@ -904,16 +1622,14 @@ public static function hasRelativeKeywords($time)
///////////////////////////////////////////////////////////////////
/**
- * Intialize the translator instance if necessary.
+ * Initialize the translator instance if necessary.
*
- * @return TranslatorInterface
+ * @return \Symfony\Component\Translation\TranslatorInterface
*/
protected static function translator()
{
if (static::$translator === null) {
- static::$translator = new Translator('en');
- static::$translator->addLoader('array', new ArrayLoader());
- static::setLocale('en');
+ static::$translator = Translator::get();
}
return static::$translator;
@@ -922,7 +1638,7 @@ protected static function translator()
/**
* Get the translator instance in use
*
- * @return TranslatorInterface
+ * @return \Symfony\Component\Translation\TranslatorInterface
*/
public static function getTranslator()
{
@@ -932,7 +1648,9 @@ public static function getTranslator()
/**
* Set the translator instance to use
*
- * @param TranslatorInterface $translator
+ * @param \Symfony\Component\Translation\TranslatorInterface $translator
+ *
+ * @return void
*/
public static function setTranslator(TranslatorInterface $translator)
{
@@ -950,81 +1668,233 @@ public static function getLocale()
}
/**
- * Set the current translator locale
+ * Set the current translator locale and indicate if the source locale file exists
*
- * @param string $locale
+ * @param string $locale locale ex. en
+ *
+ * @return bool
*/
public static function setLocale($locale)
{
- static::translator()->setLocale($locale);
-
- // Ensure the locale has been loaded.
- static::translator()->addResource('array', require __DIR__.'/Lang/'.$locale.'.php', $locale);
+ return static::translator()->setLocale($locale) !== false;
}
- ///////////////////////////////////////////////////////////////////
- /////////////////////// STRING FORMATTING /////////////////////////
- ///////////////////////////////////////////////////////////////////
-
/**
- * Format the instance with the current locale. You can set the current
- * locale using setlocale() http://php.net/setlocale.
+ * Set the current locale to the given, execute the passed function, reset the locale to previous one,
+ * then return the result of the closure (or null if the closure was void).
*
- * @param string $format
+ * @param string $locale locale ex. en
*
- * @return string
+ * @return mixed
*/
- public function formatLocalized($format)
+ public static function executeWithLocale($locale, $func)
{
- // Check for Windows to find and replace the %e
- // modifier correctly
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- $format = preg_replace('#(?trans('y')) !== 'y' &&
+ $y !== $translator->trans('year')
+ ) || (
+ ($y = $translator->trans('d')) !== 'd' &&
+ $y !== $translator->trans('day')
+ ) || (
+ ($y = $translator->trans('h')) !== 'h' &&
+ $y !== $translator->trans('hour')
+ );
+ });
}
/**
- * Set the default format used when type juggling a Carbon instance to a string
+ * Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
+ * Support is considered enabled if the 4 sentences are translated in the given locale.
*
- * @param string $format
+ * @param string $locale locale ex. en
+ *
+ * @return bool
*/
- public static function setToStringFormat($format)
+ public static function localeHasDiffSyntax($locale)
{
- static::$toStringFormat = $format;
+ return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
+ return $newLocale &&
+ $translator->trans('ago') !== 'ago' &&
+ $translator->trans('from_now') !== 'from_now' &&
+ $translator->trans('before') !== 'before' &&
+ $translator->trans('after') !== 'after';
+ });
}
/**
- * Format the instance as a string using the set format
+ * Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
+ * Support is considered enabled if the 3 words are translated in the given locale.
*
- * @return string
+ * @param string $locale locale ex. en
+ *
+ * @return bool
*/
- public function __toString()
+ public static function localeHasDiffOneDayWords($locale)
{
- return $this->format(static::$toStringFormat);
+ return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
+ return $newLocale &&
+ $translator->trans('diff_now') !== 'diff_now' &&
+ $translator->trans('diff_yesterday') !== 'diff_yesterday' &&
+ $translator->trans('diff_tomorrow') !== 'diff_tomorrow';
+ });
}
/**
- * Format the instance as date
+ * Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
+ * Support is considered enabled if the 2 words are translated in the given locale.
*
- * @return string
+ * @param string $locale locale ex. en
+ *
+ * @return bool
*/
- public function toDateString()
+ public static function localeHasDiffTwoDayWords($locale)
{
- return $this->format('Y-m-d');
+ return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
+ return $newLocale &&
+ $translator->trans('diff_before_yesterday') !== 'diff_before_yesterday' &&
+ $translator->trans('diff_after_tomorrow') !== 'diff_after_tomorrow';
+ });
}
/**
- * Format the instance as a readable date
+ * Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
+ * Support is considered enabled if the 4 sentences are translated in the given locale.
+ *
+ * @param string $locale locale ex. en
+ *
+ * @return bool
+ */
+ public static function localeHasPeriodSyntax($locale)
+ {
+ return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
+ return $newLocale &&
+ $translator->trans('period_recurrences') !== 'period_recurrences' &&
+ $translator->trans('period_interval') !== 'period_interval' &&
+ $translator->trans('period_start_date') !== 'period_start_date' &&
+ $translator->trans('period_end_date') !== 'period_end_date';
+ });
+ }
+
+ /**
+ * Returns the list of internally available locales and already loaded custom locales.
+ * (It will ignore custom translator dynamic loading.)
+ *
+ * @return array
+ */
+ public static function getAvailableLocales()
+ {
+ $translator = static::translator();
+ $locales = array();
+ if ($translator instanceof Translator) {
+ foreach (glob(__DIR__.'/Lang/*.php') as $file) {
+ $locales[] = substr($file, strrpos($file, '/') + 1, -4);
+ }
+
+ $locales = array_unique(array_merge($locales, array_keys($translator->getMessages())));
+ }
+
+ return $locales;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////// STRING FORMATTING /////////////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Set if UTF8 will be used for localized date/time
+ *
+ * @param bool $utf8
+ */
+ public static function setUtf8($utf8)
+ {
+ static::$utf8 = $utf8;
+ }
+
+ /**
+ * Format the instance with the current locale. You can set the current
+ * locale using setlocale() http://php.net/setlocale.
+ *
+ * @param string $format
+ *
+ * @return string
+ */
+ public function formatLocalized($format)
+ {
+ // Check for Windows to find and replace the %e modifier correctly.
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ $format = preg_replace('#(?toDateTimeString()));
+
+ return static::$utf8 ? utf8_encode($formatted) : $formatted;
+ }
+
+ /**
+ * Reset the format used to the default when type juggling a Carbon instance to a string
+ *
+ * @return void
+ */
+ public static function resetToStringFormat()
+ {
+ static::setToStringFormat(static::DEFAULT_TO_STRING_FORMAT);
+ }
+
+ /**
+ * Set the default format used when type juggling a Carbon instance to a string
+ *
+ * @param string|Closure $format
+ *
+ * @return void
+ */
+ public static function setToStringFormat($format)
+ {
+ static::$toStringFormat = $format;
+ }
+
+ /**
+ * Format the instance as a string using the set format
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ $format = static::$toStringFormat;
+
+ return $this->format($format instanceof Closure ? $format($this) : $format);
+ }
+
+ /**
+ * Format the instance as date
+ *
+ * @return string
+ */
+ public function toDateString()
+ {
+ return $this->format('Y-m-d');
+ }
+
+ /**
+ * Format the instance as a readable date
*
* @return string
*/
@@ -1053,6 +1923,21 @@ public function toDateTimeString()
return $this->format('Y-m-d H:i:s');
}
+ /**
+ * Format the instance as date and time T-separated with no timezone
+ *
+ * @example
+ * ```
+ * echo Carbon::now()->toDateTimeLocalString();
+ * ```
+ *
+ * @return string
+ */
+ public function toDateTimeLocalString()
+ {
+ return $this->format('Y-m-d\TH:i:s');
+ }
+
/**
* Format the instance with day, date and time
*
@@ -1090,7 +1975,7 @@ public function toCookieString()
*/
public function toIso8601String()
{
- return $this->format(static::ISO8601);
+ return $this->toAtomString();
}
/**
@@ -1103,6 +1988,16 @@ public function toRfc822String()
return $this->format(static::RFC822);
}
+ /**
+ * Convert the instance to UTC and return as Zulu ISO8601
+ *
+ * @return string
+ */
+ public function toIso8601ZuluString()
+ {
+ return $this->copy()->setTimezone('UTC')->format('Y-m-d\TH:i:s\Z');
+ }
+
/**
* Format the instance as RFC850
*
@@ -1173,373 +2068,1259 @@ public function toW3cString()
return $this->format(static::W3C);
}
- ///////////////////////////////////////////////////////////////////
- ////////////////////////// COMPARISONS ////////////////////////////
- ///////////////////////////////////////////////////////////////////
-
/**
- * Determines if the instance is equal to another
+ * Format the instance as RFC7231
*
- * @param Carbon $dt
- *
- * @return bool
+ * @return string
*/
- public function eq(Carbon $dt)
+ public function toRfc7231String()
{
- return $this == $dt;
+ return $this->copy()
+ ->setTimezone('GMT')
+ ->format(static::RFC7231_FORMAT);
}
/**
- * Determines if the instance is not equal to another
+ * Get default array representation
*
- * @param Carbon $dt
- *
- * @return bool
+ * @return array
*/
- public function ne(Carbon $dt)
+ public function toArray()
{
- return !$this->eq($dt);
+ return array(
+ 'year' => $this->year,
+ 'month' => $this->month,
+ 'day' => $this->day,
+ 'dayOfWeek' => $this->dayOfWeek,
+ 'dayOfYear' => $this->dayOfYear,
+ 'hour' => $this->hour,
+ 'minute' => $this->minute,
+ 'second' => $this->second,
+ 'micro' => $this->micro,
+ 'timestamp' => $this->timestamp,
+ 'formatted' => $this->format(self::DEFAULT_TO_STRING_FORMAT),
+ 'timezone' => $this->timezone,
+ );
}
/**
- * Determines if the instance is greater (after) than another
+ * Get default object representation.
*
- * @param Carbon $dt
+ * @example
+ * ```
+ * var_dump(Carbon::now()->toObject());
+ * ```
*
- * @return bool
+ * @return object
*/
- public function gt(Carbon $dt)
+ public function toObject()
{
- return $this > $dt;
+ return (object) $this->toArray();
}
/**
- * Determines if the instance is greater (after) than or equal to another
+ * Returns english human readable complete date string.
*
- * @param Carbon $dt
+ * @example
+ * ```
+ * echo Carbon::now()->toString();
+ * ```
*
- * @return bool
+ * @return string
*/
- public function gte(Carbon $dt)
+ public function toString()
{
- return $this >= $dt;
+ return $this->format('D M j Y H:i:s \G\M\TO');
}
/**
- * Determines if the instance is less (before) than another
+ * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept:
+ * 1977-04-22T01:00:00-05:00).
*
- * @param Carbon $dt
+ * @example
+ * ```
+ * echo Carbon::now('America/Toronto')->toISOString() . "\n";
+ * echo Carbon::now('America/Toronto')->toISOString(true) . "\n";
+ * ```
*
- * @return bool
+ * @param bool $keepOffset Pass true to keep the date offset. Else forced to UTC.
+ *
+ * @return null|string
*/
- public function lt(Carbon $dt)
+ public function toISOString($keepOffset = false)
{
- return $this < $dt;
+ if ($this->year === 0) {
+ return null;
+ }
+
+ $year = $this->year < 0 || $this->year > 9999
+ ? ($this->year < 0 ? '-' : '+').str_pad(abs($this->year), 6, '0', STR_PAD_LEFT)
+ : str_pad($this->year, 4, '0', STR_PAD_LEFT);
+ $tz = $keepOffset ? $this->format('P') : 'Z';
+ $date = $keepOffset ? $this : $this->copy()->setTimezone('UTC');
+
+ return $year.$date->format('-m-d\TH:i:s.u').$tz;
}
/**
- * Determines if the instance is less (before) or equal to another
+ * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.
*
- * @param Carbon $dt
+ * @example
+ * ```
+ * echo Carbon::now('America/Toronto')->toJSON();
+ * ```
*
- * @return bool
+ * @return null|string
*/
- public function lte(Carbon $dt)
+ public function toJSON()
{
- return $this <= $dt;
+ return $this->toISOString();
}
/**
- * Determines if the instance is between two others
+ * Return native DateTime PHP object matching the current instance.
*
- * @param Carbon $dt1
- * @param Carbon $dt2
- * @param bool $equal Indicates if a > and < comparison should be used or <= or >=
+ * @example
+ * ```
+ * var_dump(Carbon::now()->toDateTime());
+ * ```
*
- * @return bool
+ * @return DateTime
*/
- public function between(Carbon $dt1, Carbon $dt2, $equal = true)
+ public function toDateTime()
{
- if ($dt1->gt($dt2)) {
- $temp = $dt1;
- $dt1 = $dt2;
- $dt2 = $temp;
- }
-
- if ($equal) {
- return $this->gte($dt1) && $this->lte($dt2);
- }
-
- return $this->gt($dt1) && $this->lt($dt2);
+ return new DateTime($this->format('Y-m-d H:i:s.u'), $this->getTimezone());
}
/**
- * Get the closest date from the instance.
+ * @alias toDateTime
*
- * @param Carbon $dt1
- * @param Carbon $dt2
+ * Return native DateTime PHP object matching the current instance.
*
- * @return static
+ * @example
+ * ```
+ * var_dump(Carbon::now()->toDate());
+ * ```
+ *
+ * @return DateTime
*/
- public function closest(Carbon $dt1, Carbon $dt2)
+ public function toDate()
{
- return $this->diffInSeconds($dt1) < $this->diffInSeconds($dt2) ? $dt1 : $dt2;
+ return $this->toDateTime();
}
+ ///////////////////////////////////////////////////////////////////
+ ////////////////////////// COMPARISONS ////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+
/**
- * Get the farthest date from the instance.
+ * Determines if the instance is equal to another
*
- * @param Carbon $dt1
- * @param Carbon $dt2
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
- * @return static
+ * @return bool
*/
- public function farthest(Carbon $dt1, Carbon $dt2)
+ public function eq($date)
{
- return $this->diffInSeconds($dt1) > $this->diffInSeconds($dt2) ? $dt1 : $dt2;
+ return $this == $date;
}
/**
- * Get the minimum instance between a given instance (default now) and the current instance.
+ * Determines if the instance is equal to another
*
- * @param Carbon|null $dt
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
- * @return static
+ * @see eq()
+ *
+ * @return bool
*/
- public function min(Carbon $dt = null)
+ public function equalTo($date)
{
- $dt = $dt ?: static::now($this->tz);
-
- return $this->lt($dt) ? $this : $dt;
+ return $this->eq($date);
}
/**
- * Get the maximum instance between a given instance (default now) and the current instance.
+ * Determines if the instance is not equal to another
*
- * @param Carbon|null $dt
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
- * @return static
+ * @return bool
*/
- public function max(Carbon $dt = null)
+ public function ne($date)
{
- $dt = $dt ?: static::now($this->tz);
-
- return $this->gt($dt) ? $this : $dt;
+ return !$this->eq($date);
}
/**
- * Determines if the instance is a weekday
+ * Determines if the instance is not equal to another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see ne()
*
* @return bool
*/
- public function isWeekday()
+ public function notEqualTo($date)
{
- return !$this->isWeekend();
+ return $this->ne($date);
}
/**
- * Determines if the instance is a weekend day
+ * Determines if the instance is greater (after) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
* @return bool
*/
- public function isWeekend()
+ public function gt($date)
{
- return in_array($this->dayOfWeek, self::$weekendDays);
+ return $this > $date;
}
/**
- * Determines if the instance is yesterday
+ * Determines if the instance is greater (after) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see gt()
*
* @return bool
*/
- public function isYesterday()
+ public function greaterThan($date)
{
- return $this->toDateString() === static::yesterday($this->tz)->toDateString();
+ return $this->gt($date);
}
/**
- * Determines if the instance is today
+ * Determines if the instance is greater (after) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see gt()
*
* @return bool
*/
- public function isToday()
+ public function isAfter($date)
{
- return $this->toDateString() === static::now($this->tz)->toDateString();
+ return $this->gt($date);
}
/**
- * Determines if the instance is tomorrow
+ * Determines if the instance is greater (after) than or equal to another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
* @return bool
*/
- public function isTomorrow()
+ public function gte($date)
{
- return $this->toDateString() === static::tomorrow($this->tz)->toDateString();
+ return $this >= $date;
}
/**
- * Determines if the instance is in the future, ie. greater (after) than now
+ * Determines if the instance is greater (after) than or equal to another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see gte()
*
* @return bool
*/
- public function isFuture()
+ public function greaterThanOrEqualTo($date)
{
- return $this->gt(static::now($this->tz));
+ return $this->gte($date);
}
/**
- * Determines if the instance is in the past, ie. less (before) than now
+ * Determines if the instance is less (before) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
* @return bool
*/
- public function isPast()
+ public function lt($date)
{
- return $this->lt(static::now($this->tz));
+ return $this < $date;
}
/**
- * Determines if the instance is a leap year
+ * Determines if the instance is less (before) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see lt()
*
* @return bool
*/
- public function isLeapYear()
+ public function lessThan($date)
{
- return $this->format('L') === '1';
+ return $this->lt($date);
}
/**
- * Checks if the passed in date is the same day as the instance current day.
+ * Determines if the instance is less (before) than another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
- * @param Carbon $dt
+ * @see lt()
*
* @return bool
*/
- public function isSameDay(Carbon $dt)
+ public function isBefore($date)
{
- return $this->toDateString() === $dt->toDateString();
+ return $this->lt($date);
}
/**
- * Checks if this day is a Sunday.
+ * Determines if the instance is less (before) or equal to another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
*
* @return bool
*/
- public function isSunday()
+ public function lte($date)
{
- return $this->dayOfWeek === static::SUNDAY;
+ return $this <= $date;
}
/**
- * Checks if this day is a Monday.
+ * Determines if the instance is less (before) or equal to another
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see lte()
*
* @return bool
*/
- public function isMonday()
+ public function lessThanOrEqualTo($date)
{
- return $this->dayOfWeek === static::MONDAY;
+ return $this->lte($date);
}
/**
- * Checks if this day is a Tuesday.
+ * Determines if the instance is between two others
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2
+ * @param bool $equal Indicates if an equal to comparison should be done
*
* @return bool
*/
- public function isTuesday()
+ public function between($date1, $date2, $equal = true)
{
- return $this->dayOfWeek === static::TUESDAY;
+ if ($date1->gt($date2)) {
+ $temp = $date1;
+ $date1 = $date2;
+ $date2 = $temp;
+ }
+
+ if ($equal) {
+ return $this->gte($date1) && $this->lte($date2);
+ }
+
+ return $this->gt($date1) && $this->lt($date2);
}
- /**
- * Checks if this day is a Wednesday.
- *
- * @return bool
- */
- public function isWednesday()
+ protected function floatDiffInSeconds($date)
{
- return $this->dayOfWeek === static::WEDNESDAY;
+ $date = $this->resolveCarbon($date);
+
+ return abs($this->diffInRealSeconds($date, false) + ($date->micro - $this->micro) / 1000000);
}
/**
- * Checks if this day is a Thursday.
+ * Determines if the instance is between two others
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2
+ * @param bool $equal Indicates if a > and < comparison should be used or <= or >=
*
* @return bool
*/
- public function isThursday()
+ public function isBetween($date1, $date2, $equal = true)
{
- return $this->dayOfWeek === static::THURSDAY;
+ return $this->between($date1, $date2, $equal);
}
/**
- * Checks if this day is a Friday.
+ * Get the closest date from the instance.
*
- * @return bool
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2
+ *
+ * @return static
*/
- public function isFriday()
+ public function closest($date1, $date2)
{
- return $this->dayOfWeek === static::FRIDAY;
+ return $this->floatDiffInSeconds($date1) < $this->floatDiffInSeconds($date2) ? $date1 : $date2;
}
/**
- * Checks if this day is a Saturday.
+ * Get the farthest date from the instance.
*
- * @return bool
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2
+ *
+ * @return static
*/
- public function isSaturday()
+ public function farthest($date1, $date2)
{
- return $this->dayOfWeek === static::SATURDAY;
+ return $this->floatDiffInSeconds($date1) > $this->floatDiffInSeconds($date2) ? $date1 : $date2;
}
- ///////////////////////////////////////////////////////////////////
- /////////////////// ADDITIONS AND SUBTRACTIONS ////////////////////
- ///////////////////////////////////////////////////////////////////
-
/**
- * Add years to the instance. Positive $value travel forward while
- * negative $value travel into the past.
+ * Get the minimum instance between a given instance (default now) and the current instance.
*
- * @param int $value
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
*
* @return static
*/
- public function addYears($value)
+ public function min($date = null)
{
- return $this->modify((int) $value.' year');
+ $date = $this->resolveCarbon($date);
+
+ return $this->lt($date) ? $this : $date;
}
/**
- * Add a year to the instance
+ * Get the minimum instance between a given instance (default now) and the current instance.
*
- * @param int $value
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see min()
*
* @return static
*/
- public function addYear($value = 1)
+ public function minimum($date = null)
{
- return $this->addYears($value);
+ return $this->min($date);
}
/**
- * Remove a year from the instance
+ * Get the maximum instance between a given instance (default now) and the current instance.
*
- * @param int $value
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ *
+ * @return static
+ */
+ public function max($date = null)
+ {
+ $date = $this->resolveCarbon($date);
+
+ return $this->gt($date) ? $this : $date;
+ }
+
+ /**
+ * Get the maximum instance between a given instance (default now) and the current instance.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|mixed $date
+ *
+ * @see max()
+ *
+ * @return static
+ */
+ public function maximum($date = null)
+ {
+ return $this->max($date);
+ }
+
+ /**
+ * Determines if the instance is a weekday.
+ *
+ * @return bool
+ */
+ public function isWeekday()
+ {
+ return !$this->isWeekend();
+ }
+
+ /**
+ * Determines if the instance is a weekend day.
+ *
+ * @return bool
+ */
+ public function isWeekend()
+ {
+ return in_array($this->dayOfWeek, static::$weekendDays);
+ }
+
+ /**
+ * Determines if the instance is yesterday.
+ *
+ * @return bool
+ */
+ public function isYesterday()
+ {
+ return $this->toDateString() === static::yesterday($this->getTimezone())->toDateString();
+ }
+
+ /**
+ * Determines if the instance is today.
+ *
+ * @return bool
+ */
+ public function isToday()
+ {
+ return $this->toDateString() === $this->nowWithSameTz()->toDateString();
+ }
+
+ /**
+ * Determines if the instance is tomorrow.
+ *
+ * @return bool
+ */
+ public function isTomorrow()
+ {
+ return $this->toDateString() === static::tomorrow($this->getTimezone())->toDateString();
+ }
+
+ /**
+ * Determines if the instance is within the next week.
+ *
+ * @return bool
+ */
+ public function isNextWeek()
+ {
+ return $this->weekOfYear === $this->nowWithSameTz()->addWeek()->weekOfYear;
+ }
+
+ /**
+ * Determines if the instance is within the last week.
+ *
+ * @return bool
+ */
+ public function isLastWeek()
+ {
+ return $this->weekOfYear === $this->nowWithSameTz()->subWeek()->weekOfYear;
+ }
+
+ /**
+ * Determines if the instance is within the next quarter.
+ *
+ * @return bool
+ */
+ public function isNextQuarter()
+ {
+ return $this->quarter === $this->nowWithSameTz()->addQuarter()->quarter;
+ }
+
+ /**
+ * Determines if the instance is within the last quarter.
+ *
+ * @return bool
+ */
+ public function isLastQuarter()
+ {
+ return $this->quarter === $this->nowWithSameTz()->subQuarter()->quarter;
+ }
+
+ /**
+ * Determines if the instance is within the next month.
+ *
+ * @return bool
+ */
+ public function isNextMonth()
+ {
+ return $this->month === $this->nowWithSameTz()->addMonthNoOverflow()->month;
+ }
+
+ /**
+ * Determines if the instance is within the last month.
+ *
+ * @return bool
+ */
+ public function isLastMonth()
+ {
+ return $this->month === $this->nowWithSameTz()->subMonthNoOverflow()->month;
+ }
+
+ /**
+ * Determines if the instance is within next year.
+ *
+ * @return bool
+ */
+ public function isNextYear()
+ {
+ return $this->year === $this->nowWithSameTz()->addYear()->year;
+ }
+
+ /**
+ * Determines if the instance is within the previous year.
+ *
+ * @return bool
+ */
+ public function isLastYear()
+ {
+ return $this->year === $this->nowWithSameTz()->subYear()->year;
+ }
+
+ /**
+ * Determines if the instance is in the future, ie. greater (after) than now.
+ *
+ * @return bool
+ */
+ public function isFuture()
+ {
+ return $this->gt($this->nowWithSameTz());
+ }
+
+ /**
+ * Determines if the instance is in the past, ie. less (before) than now.
+ *
+ * @return bool
+ */
+ public function isPast()
+ {
+ return $this->lt($this->nowWithSameTz());
+ }
+
+ /**
+ * Determines if the instance is a leap year.
+ *
+ * @return bool
+ */
+ public function isLeapYear()
+ {
+ return $this->format('L') === '1';
+ }
+
+ /**
+ * Determines if the instance is a long year
+ *
+ * @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates
+ *
+ * @return bool
+ */
+ public function isLongYear()
+ {
+ return static::create($this->year, 12, 28, 0, 0, 0, $this->tz)->weekOfYear === 53;
+ }
+
+ /**
+ * Compares the formatted values of the two dates.
+ *
+ * @param string $format The date formats to compare.
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day.
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return bool
+ */
+ public function isSameAs($format, $date = null)
+ {
+ $date = $date ?: static::now($this->tz);
+
+ static::expectDateTime($date, 'null');
+
+ return $this->format($format) === $date->format($format);
+ }
+
+ /**
+ * Determines if the instance is in the current year.
+ *
+ * @return bool
+ */
+ public function isCurrentYear()
+ {
+ return $this->isSameYear();
+ }
+
+ /**
+ * Checks if the passed in date is in the same year as the instance year.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day.
+ *
+ * @return bool
+ */
+ public function isSameYear($date = null)
+ {
+ return $this->isSameAs('Y', $date);
+ }
+
+ /**
+ * Determines if the instance is in the current month.
+ *
+ * @return bool
+ */
+ public function isCurrentQuarter()
+ {
+ return $this->isSameQuarter();
+ }
+
+ /**
+ * Checks if the passed in date is in the same quarter as the instance quarter (and year if needed).
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day.
+ * @param bool $ofSameYear Check if it is the same month in the same year.
+ *
+ * @return bool
+ */
+ public function isSameQuarter($date = null, $ofSameYear = null)
+ {
+ $date = $date ? static::instance($date) : static::now($this->tz);
+
+ static::expectDateTime($date, 'null');
+
+ $ofSameYear = is_null($ofSameYear) ? static::shouldCompareYearWithMonth() : $ofSameYear;
+
+ return $this->quarter === $date->quarter && (!$ofSameYear || $this->isSameYear($date));
+ }
+
+ /**
+ * Determines if the instance is in the current month.
+ *
+ * @param bool $ofSameYear Check if it is the same month in the same year.
+ *
+ * @return bool
+ */
+ public function isCurrentMonth($ofSameYear = null)
+ {
+ return $this->isSameMonth(null, $ofSameYear);
+ }
+
+ /**
+ * Checks if the passed in date is in the same month as the instance´s month.
+ *
+ * Note that this defaults to only comparing the month while ignoring the year.
+ * To test if it is the same exact month of the same year, pass in true as the second parameter.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date.
+ * @param bool $ofSameYear Check if it is the same month in the same year.
+ *
+ * @return bool
+ */
+ public function isSameMonth($date = null, $ofSameYear = null)
+ {
+ $ofSameYear = is_null($ofSameYear) ? static::shouldCompareYearWithMonth() : $ofSameYear;
+
+ return $this->isSameAs($ofSameYear ? 'Y-m' : 'm', $date);
+ }
+
+ /**
+ * Determines if the instance is in the current day.
+ *
+ * @return bool
+ */
+ public function isCurrentDay()
+ {
+ return $this->isSameDay();
+ }
+
+ /**
+ * Checks if the passed in date is the same exact day as the instance´s day.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date.
+ *
+ * @return bool
+ */
+ public function isSameDay($date = null)
+ {
+ return $this->isSameAs('Y-m-d', $date);
+ }
+
+ /**
+ * Determines if the instance is in the current hour.
+ *
+ * @return bool
+ */
+ public function isCurrentHour()
+ {
+ return $this->isSameHour();
+ }
+
+ /**
+ * Checks if the passed in date is the same exact hour as the instance´s hour.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date.
+ *
+ * @return bool
+ */
+ public function isSameHour($date = null)
+ {
+ return $this->isSameAs('Y-m-d H', $date);
+ }
+
+ /**
+ * Determines if the instance is in the current minute.
+ *
+ * @return bool
+ */
+ public function isCurrentMinute()
+ {
+ return $this->isSameMinute();
+ }
+
+ /**
+ * Checks if the passed in date is the same exact minute as the instance´s minute.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date.
+ *
+ * @return bool
+ */
+ public function isSameMinute($date = null)
+ {
+ return $this->isSameAs('Y-m-d H:i', $date);
+ }
+
+ /**
+ * Determines if the instance is in the current second.
+ *
+ * @return bool
+ */
+ public function isCurrentSecond()
+ {
+ return $this->isSameSecond();
+ }
+
+ /**
+ * Checks if the passed in date is the same exact second as the instance´s second.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date.
+ *
+ * @return bool
+ */
+ public function isSameSecond($date = null)
+ {
+ return $this->isSameAs('Y-m-d H:i:s', $date);
+ }
+
+ /**
+ * Checks if this day is a specific day of the week.
+ *
+ * @param int $dayOfWeek
+ *
+ * @return bool
+ */
+ public function isDayOfWeek($dayOfWeek)
+ {
+ return $this->dayOfWeek === $dayOfWeek;
+ }
+
+ /**
+ * Checks if this day is a Sunday.
+ *
+ * @return bool
+ */
+ public function isSunday()
+ {
+ return $this->dayOfWeek === static::SUNDAY;
+ }
+
+ /**
+ * Checks if this day is a Monday.
+ *
+ * @return bool
+ */
+ public function isMonday()
+ {
+ return $this->dayOfWeek === static::MONDAY;
+ }
+
+ /**
+ * Checks if this day is a Tuesday.
+ *
+ * @return bool
+ */
+ public function isTuesday()
+ {
+ return $this->dayOfWeek === static::TUESDAY;
+ }
+
+ /**
+ * Checks if this day is a Wednesday.
+ *
+ * @return bool
+ */
+ public function isWednesday()
+ {
+ return $this->dayOfWeek === static::WEDNESDAY;
+ }
+
+ /**
+ * Checks if this day is a Thursday.
+ *
+ * @return bool
+ */
+ public function isThursday()
+ {
+ return $this->dayOfWeek === static::THURSDAY;
+ }
+
+ /**
+ * Checks if this day is a Friday.
+ *
+ * @return bool
+ */
+ public function isFriday()
+ {
+ return $this->dayOfWeek === static::FRIDAY;
+ }
+
+ /**
+ * Checks if this day is a Saturday.
+ *
+ * @return bool
+ */
+ public function isSaturday()
+ {
+ return $this->dayOfWeek === static::SATURDAY;
+ }
+
+ /**
+ * Check if its the birthday. Compares the date/month values of the two dates.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day.
+ *
+ * @return bool
+ */
+ public function isBirthday($date = null)
+ {
+ return $this->isSameAs('md', $date);
+ }
+
+ /**
+ * Check if today is the last day of the Month
+ *
+ * @return bool
+ */
+ public function isLastOfMonth()
+ {
+ return $this->day === $this->daysInMonth;
+ }
+
+ /**
+ * Check if the instance is start of day / midnight.
+ *
+ * @param bool $checkMicroseconds check time at microseconds precision
+ * /!\ Warning, this is not reliable with PHP < 7.1.4
+ *
+ * @return bool
+ */
+ public function isStartOfDay($checkMicroseconds = false)
+ {
+ return $checkMicroseconds
+ ? $this->format('H:i:s.u') === '00:00:00.000000'
+ : $this->format('H:i:s') === '00:00:00';
+ }
+
+ /**
+ * Check if the instance is end of day.
+ *
+ * @param bool $checkMicroseconds check time at microseconds precision
+ * /!\ Warning, this is not reliable with PHP < 7.1.4
+ *
+ * @return bool
+ */
+ public function isEndOfDay($checkMicroseconds = false)
+ {
+ return $checkMicroseconds
+ ? $this->format('H:i:s.u') === '23:59:59.999999'
+ : $this->format('H:i:s') === '23:59:59';
+ }
+
+ /**
+ * Check if the instance is start of day / midnight.
+ *
+ * @return bool
+ */
+ public function isMidnight()
+ {
+ return $this->isStartOfDay();
+ }
+
+ /**
+ * Check if the instance is midday.
+ *
+ * @return bool
+ */
+ public function isMidday()
+ {
+ return $this->format('G:i:s') === static::$midDayAt.':00:00';
+ }
+
+ /**
+ * Checks if the (date)time string is in a given format.
+ *
+ * @param string $date
+ * @param string $format
+ *
+ * @return bool
+ */
+ public static function hasFormat($date, $format)
+ {
+ try {
+ // Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string
+ // doesn't match the format in any way.
+ static::createFromFormat($format, $date);
+
+ // createFromFormat() is known to handle edge cases silently.
+ // E.g. "1975-5-1" (Y-n-j) will still be parsed correctly when "Y-m-d" is supplied as the format.
+ // To ensure we're really testing against our desired format, perform an additional regex validation.
+ $regex = strtr(
+ preg_quote($format, '/'),
+ static::$regexFormats
+ );
+
+ return (bool) preg_match('/^'.$regex.'$/', $date);
+ } catch (InvalidArgumentException $e) {
+ }
+
+ return false;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ /////////////////// ADDITIONS AND SUBTRACTIONS ////////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Add centuries to the instance. Positive $value travels forward while
+ * negative $value travels into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addCenturies($value)
+ {
+ return $this->addYears(static::YEARS_PER_CENTURY * $value);
+ }
+
+ /**
+ * Add a century to the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addCentury($value = 1)
+ {
+ return $this->addCenturies($value);
+ }
+
+ /**
+ * Remove centuries from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subCenturies($value)
+ {
+ return $this->addCenturies(-1 * $value);
+ }
+
+ /**
+ * Remove a century from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subCentury($value = 1)
+ {
+ return $this->subCenturies($value);
+ }
+
+ /**
+ * Add years to the instance. Positive $value travel forward while
+ * negative $value travel into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYears($value)
+ {
+ if ($this->shouldOverflowYears()) {
+ return $this->addYearsWithOverflow($value);
+ }
+
+ return $this->addYearsNoOverflow($value);
+ }
+
+ /**
+ * Add a year to the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYear($value = 1)
+ {
+ return $this->addYears($value);
+ }
+
+ /**
+ * Add years to the instance with no overflow of months
+ * Positive $value travel forward while
+ * negative $value travel into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYearsNoOverflow($value)
+ {
+ return $this->addMonthsNoOverflow($value * static::MONTHS_PER_YEAR);
+ }
+
+ /**
+ * Add year with overflow months set to false
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYearNoOverflow($value = 1)
+ {
+ return $this->addYearsNoOverflow($value);
+ }
+
+ /**
+ * Add years to the instance.
+ * Positive $value travel forward while
+ * negative $value travel into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYearsWithOverflow($value)
+ {
+ return $this->modify((int) $value.' year');
+ }
+
+ /**
+ * Add year with overflow.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addYearWithOverflow($value = 1)
+ {
+ return $this->addYearsWithOverflow($value);
+ }
+
+ /**
+ * Remove years from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subYears($value)
+ {
+ return $this->addYears(-1 * $value);
+ }
+
+ /**
+ * Remove a year from the instance
+ *
+ * @param int $value
*
* @return static
*/
public function subYear($value = 1)
{
- return $this->subYears($value);
+ return $this->subYears($value);
+ }
+
+ /**
+ * Remove years from the instance with no month overflow.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subYearsNoOverflow($value)
+ {
+ return $this->subMonthsNoOverflow($value * static::MONTHS_PER_YEAR);
+ }
+
+ /**
+ * Remove year from the instance with no month overflow
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subYearNoOverflow($value = 1)
+ {
+ return $this->subYearsNoOverflow($value);
+ }
+
+ /**
+ * Remove years from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subYearsWithOverflow($value)
+ {
+ return $this->subMonthsWithOverflow($value * static::MONTHS_PER_YEAR);
+ }
+
+ /**
+ * Remove year from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subYearWithOverflow($value = 1)
+ {
+ return $this->subYearsWithOverflow($value);
}
/**
- * Remove years from the instance.
+ * Add quarters to the instance. Positive $value travels forward while
+ * negative $value travels into the past.
*
* @param int $value
*
* @return static
*/
- public function subYears($value)
+ public function addQuarters($value)
{
- return $this->addYears(-1 * $value);
+ return $this->addMonths(static::MONTHS_PER_QUARTER * $value);
+ }
+
+ /**
+ * Add a quarter to the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addQuarter($value = 1)
+ {
+ return $this->addQuarters($value);
+ }
+
+ /**
+ * Remove quarters from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subQuarters($value)
+ {
+ return $this->addQuarters(-1 * $value);
+ }
+
+ /**
+ * Remove a quarter from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subQuarter($value = 1)
+ {
+ return $this->subQuarters($value);
}
/**
@@ -1552,7 +3333,11 @@ public function subYears($value)
*/
public function addMonths($value)
{
- return $this->modify((int) $value.' month');
+ if (static::shouldOverflowMonths()) {
+ return $this->addMonthsWithOverflow($value);
+ }
+
+ return $this->addMonthsNoOverflow($value);
}
/**
@@ -1567,6 +3352,18 @@ public function addMonth($value = 1)
return $this->addMonths($value);
}
+ /**
+ * Remove months from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subMonths($value)
+ {
+ return $this->addMonths(-1 * $value);
+ }
+
/**
* Remove a month from the instance
*
@@ -1579,6 +3376,31 @@ public function subMonth($value = 1)
return $this->subMonths($value);
}
+ /**
+ * Add months to the instance. Positive $value travels forward while
+ * negative $value travels into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addMonthsWithOverflow($value)
+ {
+ return $this->modify((int) $value.' month');
+ }
+
+ /**
+ * Add a month to the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addMonthWithOverflow($value = 1)
+ {
+ return $this->addMonthsWithOverflow($value);
+ }
+
/**
* Remove months from the instance
*
@@ -1586,9 +3408,21 @@ public function subMonth($value = 1)
*
* @return static
*/
- public function subMonths($value)
+ public function subMonthsWithOverflow($value)
{
- return $this->addMonths(-1 * $value);
+ return $this->addMonthsWithOverflow(-1 * $value);
+ }
+
+ /**
+ * Remove a month from the instance
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subMonthWithOverflow($value = 1)
+ {
+ return $this->subMonthsWithOverflow($value);
}
/**
@@ -1601,13 +3435,15 @@ public function subMonths($value)
*/
public function addMonthsNoOverflow($value)
{
- $date = $this->copy()->addMonths($value);
+ $day = $this->day;
+
+ $this->modify((int) $value.' month');
- if ($date->day !== $this->day) {
- $date->day(1)->subMonth()->day($date->daysInMonth);
+ if ($day !== $this->day) {
+ $this->modify('last day of previous month');
}
- return $date;
+ return $this;
}
/**
@@ -1623,27 +3459,27 @@ public function addMonthNoOverflow($value = 1)
}
/**
- * Remove a month with no overflow from the instance
+ * Remove months with no overflow from the instance
*
* @param int $value
*
* @return static
*/
- public function subMonthNoOverflow($value = 1)
+ public function subMonthsNoOverflow($value)
{
- return $this->subMonthsNoOverflow($value);
+ return $this->addMonthsNoOverflow(-1 * $value);
}
/**
- * Remove months with no overflow from the instance
+ * Remove a month with no overflow from the instance
*
* @param int $value
*
* @return static
*/
- public function subMonthsNoOverflow($value)
+ public function subMonthNoOverflow($value = 1)
{
- return $this->addMonthsNoOverflow(-1 * $value);
+ return $this->subMonthsNoOverflow($value);
}
/**
@@ -1672,27 +3508,27 @@ public function addDay($value = 1)
}
/**
- * Remove a day from the instance
+ * Remove days from the instance
*
* @param int $value
*
* @return static
*/
- public function subDay($value = 1)
+ public function subDays($value)
{
- return $this->subDays($value);
+ return $this->addDays(-1 * $value);
}
/**
- * Remove days from the instance
+ * Remove a day from the instance
*
* @param int $value
*
* @return static
*/
- public function subDays($value)
+ public function subDay($value = 1)
{
- return $this->addDays(-1 * $value);
+ return $this->subDays($value);
}
/**
@@ -1705,7 +3541,11 @@ public function subDays($value)
*/
public function addWeekdays($value)
{
- return $this->modify((int) $value.' weekday');
+ // Fix for weekday bug https://bugs.php.net/bug.php?id=54909
+ $t = $this->toTimeString();
+ $this->modify((int) $value.' weekday');
+
+ return $this->setTimeFromTimeString($t);
}
/**
@@ -1721,27 +3561,27 @@ public function addWeekday($value = 1)
}
/**
- * Remove a weekday from the instance
+ * Remove weekdays from the instance
*
* @param int $value
*
* @return static
*/
- public function subWeekday($value = 1)
+ public function subWeekdays($value)
{
- return $this->subWeekdays($value);
+ return $this->addWeekdays(-1 * $value);
}
/**
- * Remove weekdays from the instance
+ * Remove a weekday from the instance
*
* @param int $value
*
* @return static
*/
- public function subWeekdays($value)
+ public function subWeekday($value = 1)
{
- return $this->addWeekdays(-1 * $value);
+ return $this->subWeekdays($value);
}
/**
@@ -1770,27 +3610,27 @@ public function addWeek($value = 1)
}
/**
- * Remove a week from the instance
+ * Remove weeks to the instance
*
* @param int $value
*
* @return static
*/
- public function subWeek($value = 1)
+ public function subWeeks($value)
{
- return $this->subWeeks($value);
+ return $this->addWeeks(-1 * $value);
}
/**
- * Remove weeks to the instance
+ * Remove a week from the instance
*
* @param int $value
*
* @return static
*/
- public function subWeeks($value)
+ public function subWeek($value = 1)
{
- return $this->addWeeks(-1 * $value);
+ return $this->subWeeks($value);
}
/**
@@ -1807,7 +3647,20 @@ public function addHours($value)
}
/**
- * Add an hour to the instance
+ * Add hours to the instance using timestamp. Positive $value travels
+ * forward while negative $value travels into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addRealHours($value)
+ {
+ return $this->addRealMinutes($value * static::MINUTES_PER_HOUR);
+ }
+
+ /**
+ * Add an hour to the instance.
*
* @param int $value
*
@@ -1819,7 +3672,43 @@ public function addHour($value = 1)
}
/**
- * Remove an hour from the instance
+ * Add an hour to the instance using timestamp.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addRealHour($value = 1)
+ {
+ return $this->addRealHours($value);
+ }
+
+ /**
+ * Remove hours from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subHours($value)
+ {
+ return $this->addHours(-1 * $value);
+ }
+
+ /**
+ * Remove hours from the instance using timestamp.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subRealHours($value)
+ {
+ return $this->addRealHours(-1 * $value);
+ }
+
+ /**
+ * Remove an hour from the instance.
*
* @param int $value
*
@@ -1831,89 +3720,187 @@ public function subHour($value = 1)
}
/**
- * Remove hours from the instance
+ * Remove an hour from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subRealHour($value = 1)
+ {
+ return $this->subRealHours($value);
+ }
+
+ /**
+ * Add minutes to the instance using timestamp. Positive $value
+ * travels forward while negative $value travels into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addMinutes($value)
+ {
+ return $this->modify((int) $value.' minute');
+ }
+
+ /**
+ * Add minutes to the instance using timestamp. Positive $value travels
+ * forward while negative $value travels into the past.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addRealMinutes($value)
+ {
+ return $this->addRealSeconds($value * static::SECONDS_PER_MINUTE);
+ }
+
+ /**
+ * Add a minute to the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addMinute($value = 1)
+ {
+ return $this->addMinutes($value);
+ }
+
+ /**
+ * Add a minute to the instance using timestamp.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function addRealMinute($value = 1)
+ {
+ return $this->addRealMinutes($value);
+ }
+
+ /**
+ * Remove a minute from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subMinute($value = 1)
+ {
+ return $this->subMinutes($value);
+ }
+
+ /**
+ * Remove a minute from the instance using timestamp.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subRealMinute($value = 1)
+ {
+ return $this->addRealMinutes(-1 * $value);
+ }
+
+ /**
+ * Remove minutes from the instance.
+ *
+ * @param int $value
+ *
+ * @return static
+ */
+ public function subMinutes($value)
+ {
+ return $this->addMinutes(-1 * $value);
+ }
+
+ /**
+ * Remove a minute from the instance using timestamp.
*
* @param int $value
*
* @return static
*/
- public function subHours($value)
+ public function subRealMinutes($value = 1)
{
- return $this->addHours(-1 * $value);
+ return $this->subRealMinute($value);
}
/**
- * Add minutes to the instance. Positive $value travels forward while
+ * Add seconds to the instance. Positive $value travels forward while
* negative $value travels into the past.
*
* @param int $value
*
* @return static
*/
- public function addMinutes($value)
+ public function addSeconds($value)
{
- return $this->modify((int) $value.' minute');
+ return $this->modify((int) $value.' second');
}
/**
- * Add a minute to the instance
+ * Add seconds to the instance using timestamp. Positive $value travels
+ * forward while negative $value travels into the past.
*
* @param int $value
*
* @return static
*/
- public function addMinute($value = 1)
+ public function addRealSeconds($value)
{
- return $this->addMinutes($value);
+ return $this->setTimestamp($this->getTimestamp() + $value);
}
/**
- * Remove a minute from the instance
+ * Add a second to the instance.
*
* @param int $value
*
* @return static
*/
- public function subMinute($value = 1)
+ public function addSecond($value = 1)
{
- return $this->subMinutes($value);
+ return $this->addSeconds($value);
}
/**
- * Remove minutes from the instance
+ * Add a second to the instance using timestamp.
*
* @param int $value
*
* @return static
*/
- public function subMinutes($value)
+ public function addRealSecond($value = 1)
{
- return $this->addMinutes(-1 * $value);
+ return $this->addRealSeconds($value);
}
/**
- * Add seconds to the instance. Positive $value travels forward while
- * negative $value travels into the past.
+ * Remove seconds from the instance.
*
* @param int $value
*
* @return static
*/
- public function addSeconds($value)
+ public function subSeconds($value)
{
- return $this->modify((int) $value.' second');
+ return $this->addSeconds(-1 * $value);
}
/**
- * Add a second to the instance
+ * Remove seconds from the instance using timestamp.
*
* @param int $value
*
* @return static
*/
- public function addSecond($value = 1)
+ public function subRealSeconds($value)
{
- return $this->addSeconds($value);
+ return $this->addRealSeconds(-1 * $value);
}
/**
@@ -1929,121 +3916,205 @@ public function subSecond($value = 1)
}
/**
- * Remove seconds from the instance
+ * Remove a second from the instance using timestamp.
*
* @param int $value
*
* @return static
*/
- public function subSeconds($value)
+ public function subRealSecond($value = 1)
{
- return $this->addSeconds(-1 * $value);
+ return $this->subRealSeconds($value);
}
///////////////////////////////////////////////////////////////////
/////////////////////////// DIFFERENCES ///////////////////////////
///////////////////////////////////////////////////////////////////
+ /**
+ * @param DateInterval $diff
+ * @param bool $absolute
+ * @param bool $trimMicroseconds
+ *
+ * @return CarbonInterval
+ */
+ protected static function fixDiffInterval(DateInterval $diff, $absolute, $trimMicroseconds)
+ {
+ $diff = CarbonInterval::instance($diff, $trimMicroseconds);
+
+ // @codeCoverageIgnoreStart
+ if (version_compare(PHP_VERSION, '7.1.0-dev', '<')) {
+ return $diff;
+ }
+
+ // Work-around for https://bugs.php.net/bug.php?id=77145
+ if ($diff->f > 0 && $diff->y === -1 && $diff->m === 11 && $diff->d >= 27 && $diff->h === 23 && $diff->i === 59 && $diff->s === 59) {
+ $diff->y = 0;
+ $diff->m = 0;
+ $diff->d = 0;
+ $diff->h = 0;
+ $diff->i = 0;
+ $diff->s = 0;
+ $diff->f = (1000000 - round($diff->f * 1000000)) / 1000000;
+ $diff->invert();
+ } elseif ($diff->f < 0) {
+ if ($diff->s !== 0 || $diff->i !== 0 || $diff->h !== 0 || $diff->d !== 0 || $diff->m !== 0 || $diff->y !== 0) {
+ $diff->f = (round($diff->f * 1000000) + 1000000) / 1000000;
+ $diff->s--;
+ if ($diff->s < 0) {
+ $diff->s += 60;
+ $diff->i--;
+ if ($diff->i < 0) {
+ $diff->i += 60;
+ $diff->h--;
+ if ($diff->h < 0) {
+ $diff->h += 24;
+ $diff->d--;
+ if ($diff->d < 0) {
+ $diff->d += 30;
+ $diff->m--;
+ if ($diff->m < 0) {
+ $diff->m += 12;
+ $diff->y--;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ $diff->f *= -1;
+ $diff->invert();
+ }
+ }
+ // @codeCoverageIgnoreEnd
+ if ($absolute && $diff->invert) {
+ $diff->invert();
+ }
+
+ return $diff;
+ }
+
+ /**
+ * Get the difference as a CarbonInterval instance.
+ *
+ * Pass false as second argument to get a microseconds-precise interval. Else
+ * microseconds in the original interval will not be kept.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ * @param bool $trimMicroseconds (true by default)
+ *
+ * @return CarbonInterval
+ */
+ public function diffAsCarbonInterval($date = null, $absolute = true, $trimMicroseconds = true)
+ {
+ $from = $this;
+ $to = $this->resolveCarbon($date);
+
+ if ($trimMicroseconds) {
+ $from = $from->copy()->startOfSecond();
+ $to = $to->copy()->startOfSecond();
+ }
+
+ return static::fixDiffInterval($from->diff($to, $absolute), $absolute, $trimMicroseconds);
+ }
+
/**
* Get the difference in years
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInYears(Carbon $dt = null, $abs = true)
+ public function diffInYears($date = null, $absolute = true)
{
- $dt = $dt ?: static::now($this->tz);
-
- return (int) $this->diff($dt, $abs)->format('%r%y');
+ return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%y');
}
/**
* Get the difference in months
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInMonths(Carbon $dt = null, $abs = true)
+ public function diffInMonths($date = null, $absolute = true)
{
- $dt = $dt ?: static::now($this->tz);
+ $date = $this->resolveCarbon($date);
- return $this->diffInYears($dt, $abs) * static::MONTHS_PER_YEAR + (int) $this->diff($dt, $abs)->format('%r%m');
+ return $this->diffInYears($date, $absolute) * static::MONTHS_PER_YEAR + (int) $this->diff($date, $absolute)->format('%r%m');
}
/**
* Get the difference in weeks
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInWeeks(Carbon $dt = null, $abs = true)
+ public function diffInWeeks($date = null, $absolute = true)
{
- return (int) ($this->diffInDays($dt, $abs) / static::DAYS_PER_WEEK);
+ return (int) ($this->diffInDays($date, $absolute) / static::DAYS_PER_WEEK);
}
/**
* Get the difference in days
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInDays(Carbon $dt = null, $abs = true)
+ public function diffInDays($date = null, $absolute = true)
{
- $dt = $dt ?: static::now($this->tz);
-
- return (int) $this->diff($dt, $abs)->format('%r%a');
+ return (int) $this->diff($this->resolveCarbon($date), $absolute)->format('%r%a');
}
/**
* Get the difference in days using a filter closure
*
- * @param Closure $callback
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param Closure $callback
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInDaysFiltered(Closure $callback, Carbon $dt = null, $abs = true)
+ public function diffInDaysFiltered(Closure $callback, $date = null, $absolute = true)
{
- return $this->diffFiltered(CarbonInterval::day(), $callback, $dt, $abs);
+ return $this->diffFiltered(CarbonInterval::day(), $callback, $date, $absolute);
}
/**
* Get the difference in hours using a filter closure
*
- * @param Closure $callback
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param Closure $callback
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInHoursFiltered(Closure $callback, Carbon $dt = null, $abs = true)
+ public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true)
{
- return $this->diffFiltered(CarbonInterval::hour(), $callback, $dt, $abs);
+ return $this->diffFiltered(CarbonInterval::hour(), $callback, $date, $absolute);
}
/**
* Get the difference by the given interval using a filter closure
*
- * @param CarbonInterval $ci An interval to traverse by
- * @param Closure $callback
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param CarbonInterval $ci An interval to traverse by
+ * @param Closure $callback
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffFiltered(CarbonInterval $ci, Closure $callback, Carbon $dt = null, $abs = true)
+ public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, $absolute = true)
{
$start = $this;
- $end = $dt ?: static::now($this->tz);
+ $end = $this->resolveCarbon($date);
$inverse = false;
if ($end < $start) {
@@ -2053,85 +4124,197 @@ public function diffFiltered(CarbonInterval $ci, Closure $callback, Carbon $dt =
}
$period = new DatePeriod($start, $ci, $end);
- $vals = array_filter(iterator_to_array($period), function (DateTime $date) use ($callback) {
+ $values = array_filter(iterator_to_array($period), function ($date) use ($callback) {
return call_user_func($callback, Carbon::instance($date));
});
- $diff = count($vals);
+ $diff = count($values);
- return $inverse && !$abs ? -$diff : $diff;
+ return $inverse && !$absolute ? -$diff : $diff;
}
/**
* Get the difference in weekdays
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInWeekdays(Carbon $dt = null, $abs = true)
+ public function diffInWeekdays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (Carbon $date) {
return $date->isWeekday();
- }, $dt, $abs);
+ }, $date, $absolute);
}
/**
* Get the difference in weekend days using a filter
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInWeekendDays(Carbon $dt = null, $abs = true)
+ public function diffInWeekendDays($date = null, $absolute = true)
{
return $this->diffInDaysFiltered(function (Carbon $date) {
return $date->isWeekend();
- }, $dt, $abs);
+ }, $date, $absolute);
+ }
+
+ /**
+ * Get the difference in hours.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInHours($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
+ }
+
+ /**
+ * Get the difference in hours using timestamps.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInRealHours($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
+ }
+
+ /**
+ * Get the difference in minutes.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInMinutes($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
+ }
+
+ /**
+ * Get the difference in minutes using timestamps.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInRealMinutes($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInRealSeconds($date, $absolute) / static::SECONDS_PER_MINUTE);
+ }
+
+ /**
+ * Get the difference in seconds.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInSeconds($date = null, $absolute = true)
+ {
+ $diff = $this->diff($this->resolveCarbon($date));
+ if (!$diff->days && version_compare(PHP_VERSION, '5.4.0-dev', '>=')) {
+ $diff = static::fixDiffInterval($diff, $absolute, false);
+ }
+ $value = $diff->days * static::HOURS_PER_DAY * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE +
+ $diff->h * static::MINUTES_PER_HOUR * static::SECONDS_PER_MINUTE +
+ $diff->i * static::SECONDS_PER_MINUTE +
+ $diff->s;
+
+ return $absolute || !$diff->invert ? $value : -$value;
}
/**
- * Get the difference in hours
+ * Get the difference in seconds using timestamps.
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInHours(Carbon $dt = null, $abs = true)
+ public function diffInRealSeconds($date = null, $absolute = true)
{
- return (int) ($this->diffInSeconds($dt, $abs) / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR);
+ $date = $this->resolveCarbon($date);
+ $value = $date->getTimestamp() - $this->getTimestamp();
+
+ return $absolute ? abs($value) : $value;
+ }
+
+ /**
+ * Get the difference in milliseconds.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInMilliseconds($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
+ }
+
+ /**
+ * Get the difference in milliseconds using timestamps.
+ *
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
+ *
+ * @return int
+ */
+ public function diffInRealMilliseconds($date = null, $absolute = true)
+ {
+ return (int) ($this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_MILLISECOND);
}
/**
- * Get the difference in minutes
+ * Get the difference in microseconds.
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInMinutes(Carbon $dt = null, $abs = true)
+ public function diffInMicroseconds($date = null, $absolute = true)
{
- return (int) ($this->diffInSeconds($dt, $abs) / static::SECONDS_PER_MINUTE);
+ $diff = $this->diff($this->resolveCarbon($date));
+ $micro = isset($diff->f) ? $diff->f : 0;
+ $value = (int) round((((($diff->days * static::HOURS_PER_DAY) +
+ $diff->h) * static::MINUTES_PER_HOUR +
+ $diff->i) * static::SECONDS_PER_MINUTE +
+ ($micro + $diff->s)) * static::MICROSECONDS_PER_SECOND);
+
+ return $absolute || !$diff->invert ? $value : -$value;
}
/**
- * Get the difference in seconds
+ * Get the difference in microseconds using timestamps.
*
- * @param Carbon|null $dt
- * @param bool $abs Get the absolute of the difference
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
+ * @param bool $absolute Get the absolute of the difference
*
* @return int
*/
- public function diffInSeconds(Carbon $dt = null, $abs = true)
+ public function diffInRealMicroseconds($date = null, $absolute = true)
{
- $dt = $dt ?: static::now($this->tz);
- $value = $dt->getTimestamp() - $this->getTimestamp();
+ /** @var Carbon $date */
+ $date = $this->resolveCarbon($date);
+ $value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
+ $date->micro - $this->micro;
- return $abs ? abs($value) : $value;
+ return $absolute ? abs($value) : $value;
}
/**
@@ -2145,7 +4328,7 @@ public function secondsSinceMidnight()
}
/**
- * The number of seconds until 23:23:59.
+ * The number of seconds until 23:59:59.
*
* @return int
*/
@@ -2175,76 +4358,309 @@ public function secondsUntilEndOfDay()
*
* @param Carbon|null $other
* @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
*
* @return string
*/
- public function diffForHumans(Carbon $other = null, $absolute = false)
+ public function diffForHumans($other = null, $absolute = false, $short = false, $parts = 1)
{
$isNow = $other === null;
+ $relativeToNow = $isNow;
+
+ if ($absolute === static::DIFF_RELATIVE_TO_NOW) {
+ $absolute = false;
+ $relativeToNow = true;
+ } elseif ($absolute === static::DIFF_RELATIVE_TO_OTHER) {
+ $absolute = false;
+ $relativeToNow = false;
+ }
+
+ $interval = array();
+
+ $parts = min(6, max(1, (int) $parts));
+ $count = 1;
+ $unit = $short ? 's' : 'second';
if ($isNow) {
- $other = static::now($this->tz);
+ $other = $this->nowWithSameTz();
+ } elseif (!$other instanceof DateTime && !$other instanceof DateTimeInterface) {
+ $other = static::parse($other);
}
$diffInterval = $this->diff($other);
- switch (true) {
- case ($diffInterval->y > 0):
- $unit = 'year';
- $count = $diffInterval->y;
- break;
+ $diffIntervalArray = array(
+ array('value' => $diffInterval->y, 'unit' => 'year', 'unitShort' => 'y'),
+ array('value' => $diffInterval->m, 'unit' => 'month', 'unitShort' => 'm'),
+ array('value' => $diffInterval->d, 'unit' => 'day', 'unitShort' => 'd'),
+ array('value' => $diffInterval->h, 'unit' => 'hour', 'unitShort' => 'h'),
+ array('value' => $diffInterval->i, 'unit' => 'minute', 'unitShort' => 'min'),
+ array('value' => $diffInterval->s, 'unit' => 'second', 'unitShort' => 's'),
+ );
+
+ foreach ($diffIntervalArray as $diffIntervalData) {
+ if ($diffIntervalData['value'] > 0) {
+ $unit = $short ? $diffIntervalData['unitShort'] : $diffIntervalData['unit'];
+ $count = $diffIntervalData['value'];
+
+ if ($diffIntervalData['unit'] === 'day' && $count >= static::DAYS_PER_WEEK) {
+ $unit = $short ? 'w' : 'week';
+ $count = (int) ($count / static::DAYS_PER_WEEK);
+
+ $interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count));
+
+ // get the count days excluding weeks (might be zero)
+ $numOfDaysCount = (int) ($diffIntervalData['value'] - ($count * static::DAYS_PER_WEEK));
+
+ if ($numOfDaysCount > 0 && count($interval) < $parts) {
+ $unit = $short ? 'd' : 'day';
+ $count = $numOfDaysCount;
+ $interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count));
+ }
+ } else {
+ $interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count));
+ }
+ }
- case ($diffInterval->m > 0):
- $unit = 'month';
- $count = $diffInterval->m;
+ // break the loop after we get the required number of parts in array
+ if (count($interval) >= $parts) {
break;
+ }
+ }
- case ($diffInterval->d > 0):
- $unit = 'day';
- $count = $diffInterval->d;
- if ($count >= self::DAYS_PER_WEEK) {
- $unit = 'week';
- $count = (int) ($count / self::DAYS_PER_WEEK);
+ if (count($interval) === 0) {
+ if ($isNow && static::getHumanDiffOptions() & self::JUST_NOW) {
+ $key = 'diff_now';
+ $translation = static::translator()->trans($key);
+ if ($translation !== $key) {
+ return $translation;
}
- break;
+ }
+ $count = static::getHumanDiffOptions() & self::NO_ZERO_DIFF ? 1 : 0;
+ $unit = $short ? 's' : 'second';
+ $interval[] = static::translator()->transChoice($unit, $count, array(':count' => $count));
+ }
- case ($diffInterval->h > 0):
- $unit = 'hour';
- $count = $diffInterval->h;
- break;
+ // join the interval parts by a space
+ $time = implode(' ', $interval);
- case ($diffInterval->i > 0):
- $unit = 'minute';
- $count = $diffInterval->i;
- break;
+ unset($diffIntervalArray, $interval);
- default:
- $count = $diffInterval->s;
- $unit = 'second';
- break;
+ if ($absolute) {
+ return $time;
}
- if ($count === 0) {
- $count = 1;
+ $isFuture = $diffInterval->invert === 1;
+
+ $transId = $relativeToNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before');
+
+ if ($parts === 1) {
+ if ($isNow && $unit === 'day') {
+ if ($count === 1 && static::getHumanDiffOptions() & self::ONE_DAY_WORDS) {
+ $key = $isFuture ? 'diff_tomorrow' : 'diff_yesterday';
+ $translation = static::translator()->trans($key);
+ if ($translation !== $key) {
+ return $translation;
+ }
+ }
+ if ($count === 2 && static::getHumanDiffOptions() & self::TWO_DAY_WORDS) {
+ $key = $isFuture ? 'diff_after_tomorrow' : 'diff_before_yesterday';
+ $translation = static::translator()->trans($key);
+ if ($translation !== $key) {
+ return $translation;
+ }
+ }
+ }
+ // Some languages have special pluralization for past and future tense.
+ $key = $unit.'_'.$transId;
+ if ($key !== static::translator()->transChoice($key, $count)) {
+ $time = static::translator()->transChoice($key, $count, array(':count' => $count));
+ }
}
- $time = static::translator()->transChoice($unit, $count, array(':count' => $count));
+ return static::translator()->trans($transId, array(':time' => $time));
+ }
- if ($absolute) {
- return $time;
+ /**
+ * @alias diffForHumans
+ *
+ * Get the difference in a human readable format in the current locale.
+ *
+ * When comparing a value in the past to default now:
+ * 1 hour ago
+ * 5 months ago
+ *
+ * When comparing a value in the future to default now:
+ * 1 hour from now
+ * 5 months from now
+ *
+ * When comparing a value in the past to another value:
+ * 1 hour before
+ * 5 months before
+ *
+ * When comparing a value in the future to another value:
+ * 1 hour after
+ * 5 months after
+ *
+ * @param Carbon|null $other
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function from($other = null, $absolute = false, $short = false, $parts = 1)
+ {
+ if (!$other && !$absolute) {
+ $absolute = static::DIFF_RELATIVE_TO_NOW;
}
- $isFuture = $diffInterval->invert === 1;
+ return $this->diffForHumans($other, $absolute, $short, $parts);
+ }
+
+ /**
+ * @alias diffForHumans
+ *
+ * Get the difference in a human readable format in the current locale.
+ *
+ * When comparing a value in the past to default now:
+ * 1 hour ago
+ * 5 months ago
+ *
+ * When comparing a value in the future to default now:
+ * 1 hour from now
+ * 5 months from now
+ *
+ * When comparing a value in the past to another value:
+ * 1 hour before
+ * 5 months before
+ *
+ * When comparing a value in the future to another value:
+ * 1 hour after
+ * 5 months after
+ *
+ * @param Carbon|null $other
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function since($other = null, $absolute = false, $short = false, $parts = 1)
+ {
+ return $this->diffForHumans($other, $absolute, $short, $parts);
+ }
+
+ /**
+ * Get the difference in a human readable format in the current locale from an other
+ * instance given (or now if null given) to current instance.
+ *
+ * When comparing a value in the past to default now:
+ * 1 hour from now
+ * 5 months from now
+ *
+ * When comparing a value in the future to default now:
+ * 1 hour ago
+ * 5 months ago
+ *
+ * When comparing a value in the past to another value:
+ * 1 hour after
+ * 5 months after
+ *
+ * When comparing a value in the future to another value:
+ * 1 hour before
+ * 5 months before
+ *
+ * @param Carbon|null $other
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function to($other = null, $absolute = false, $short = false, $parts = 1)
+ {
+ if (!$other && !$absolute) {
+ $absolute = static::DIFF_RELATIVE_TO_NOW;
+ }
+
+ return $this->resolveCarbon($other)->diffForHumans($this, $absolute, $short, $parts);
+ }
+
+ /**
+ * @alias to
+ *
+ * Get the difference in a human readable format in the current locale from an other
+ * instance given (or now if null given) to current instance.
+ *
+ * @param Carbon|null $other
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function until($other = null, $absolute = false, $short = false, $parts = 1)
+ {
+ return $this->to($other, $absolute, $short, $parts);
+ }
+
+ /**
+ * Get the difference in a human readable format in the current locale from current
+ * instance to now.
+ *
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function fromNow($absolute = null, $short = false, $parts = 1)
+ {
+ $other = null;
+
+ if ($absolute instanceof DateTimeInterface) {
+ list($other, $absolute, $short, $parts) = array_pad(func_get_args(), 5, null);
+ }
+
+ return $this->from($other, $absolute, $short, $parts);
+ }
+
+ /**
+ * Get the difference in a human readable format in the current locale from an other
+ * instance given to now
+ *
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function toNow($absolute = null, $short = false, $parts = 1)
+ {
+ return $this->to(null, $absolute, $short, $parts);
+ }
- $transId = $isNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before');
+ /**
+ * Get the difference in a human readable format in the current locale from an other
+ * instance given to now
+ *
+ * @param bool $absolute removes time difference modifiers ago, after, etc
+ * @param bool $short displays short format of time units
+ * @param int $parts displays number of parts in the interval
+ *
+ * @return string
+ */
+ public function ago($absolute = null, $short = false, $parts = 1)
+ {
+ $other = null;
- // Some langs have special pluralization for past and future tense.
- $tryKeyExists = $unit.'_'.$transId;
- if ($tryKeyExists !== static::translator()->transChoice($tryKeyExists, $count)) {
- $time = static::translator()->transChoice($tryKeyExists, $count, array(':count' => $count));
+ if ($absolute instanceof DateTimeInterface) {
+ list($other, $absolute, $short, $parts) = array_pad(func_get_args(), 5, null);
}
- return static::translator()->trans($transId, array(':time' => $time));
+ return $this->from($other, $absolute, $short, $parts);
}
///////////////////////////////////////////////////////////////////
@@ -2252,23 +4668,23 @@ public function diffForHumans(Carbon $other = null, $absolute = false)
///////////////////////////////////////////////////////////////////
/**
- * Resets the time to 00:00:00
+ * Resets the time to 00:00:00 start of day
*
* @return static
*/
public function startOfDay()
{
- return $this->hour(0)->minute(0)->second(0);
+ return $this->modify('00:00:00.000000');
}
/**
- * Resets the time to 23:59:59
+ * Resets the time to 23:59:59 end of day
*
* @return static
*/
public function endOfDay()
{
- return $this->hour(23)->minute(59)->second(59);
+ return $this->modify('23:59:59.999999');
}
/**
@@ -2278,7 +4694,7 @@ public function endOfDay()
*/
public function startOfMonth()
{
- return $this->startOfDay()->day(1);
+ return $this->setDate($this->year, $this->month, 1)->startOfDay();
}
/**
@@ -2288,7 +4704,29 @@ public function startOfMonth()
*/
public function endOfMonth()
{
- return $this->day($this->daysInMonth)->endOfDay();
+ return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
+ }
+
+ /**
+ * Resets the date to the first day of the quarter and the time to 00:00:00
+ *
+ * @return static
+ */
+ public function startOfQuarter()
+ {
+ $month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;
+
+ return $this->setDate($this->year, $month, 1)->startOfDay();
+ }
+
+ /**
+ * Resets the date to end of the quarter and time to 23:59:59
+ *
+ * @return static
+ */
+ public function endOfQuarter()
+ {
+ return $this->startOfQuarter()->addMonths(static::MONTHS_PER_QUARTER - 1)->endOfMonth();
}
/**
@@ -2298,7 +4736,7 @@ public function endOfMonth()
*/
public function startOfYear()
{
- return $this->month(1)->startOfMonth();
+ return $this->setDate($this->year, 1, 1)->startOfDay();
}
/**
@@ -2308,7 +4746,7 @@ public function startOfYear()
*/
public function endOfYear()
{
- return $this->month(static::MONTHS_PER_YEAR)->endOfMonth();
+ return $this->setDate($this->year, 12, 31)->endOfDay();
}
/**
@@ -2318,7 +4756,9 @@ public function endOfYear()
*/
public function startOfDecade()
{
- return $this->startOfYear()->year($this->year - $this->year % static::YEARS_PER_DECADE);
+ $year = $this->year - $this->year % static::YEARS_PER_DECADE;
+
+ return $this->setDate($year, 1, 1)->startOfDay();
}
/**
@@ -2328,7 +4768,9 @@ public function startOfDecade()
*/
public function endOfDecade()
{
- return $this->endOfYear()->year($this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1);
+ $year = $this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1;
+
+ return $this->setDate($year, 12, 31)->endOfDay();
}
/**
@@ -2338,7 +4780,9 @@ public function endOfDecade()
*/
public function startOfCentury()
{
- return $this->startOfYear()->year($this->year - $this->year % static::YEARS_PER_CENTURY);
+ $year = $this->year - ($this->year - 1) % static::YEARS_PER_CENTURY;
+
+ return $this->setDate($year, 1, 1)->startOfDay();
}
/**
@@ -2348,7 +4792,33 @@ public function startOfCentury()
*/
public function endOfCentury()
{
- return $this->endOfYear()->year($this->year - $this->year % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY - 1);
+ $year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY;
+
+ return $this->setDate($year, 12, 31)->endOfDay();
+ }
+
+ /**
+ * Resets the date to the first day of the century and the time to 00:00:00
+ *
+ * @return static
+ */
+ public function startOfMillennium()
+ {
+ $year = $this->year - ($this->year - 1) % static::YEARS_PER_MILLENNIUM;
+
+ return $this->setDate($year, 1, 1)->startOfDay();
+ }
+
+ /**
+ * Resets the date to end of the century and time to 23:59:59
+ *
+ * @return static
+ */
+ public function endOfMillennium()
+ {
+ $year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_MILLENNIUM + static::YEARS_PER_MILLENNIUM;
+
+ return $this->setDate($year, 12, 31)->endOfDay();
}
/**
@@ -2358,8 +4828,8 @@ public function endOfCentury()
*/
public function startOfWeek()
{
- if ($this->dayOfWeek !== static::$weekStartsAt) {
- $this->previous(static::$weekStartsAt);
+ while ($this->dayOfWeek !== static::$weekStartsAt) {
+ $this->subDay();
}
return $this->startOfDay();
@@ -2372,17 +4842,87 @@ public function startOfWeek()
*/
public function endOfWeek()
{
- if ($this->dayOfWeek !== static::$weekEndsAt) {
- $this->next(static::$weekEndsAt);
+ while ($this->dayOfWeek !== static::$weekEndsAt) {
+ $this->addDay();
}
return $this->endOfDay();
}
+ /**
+ * Modify to start of current hour, minutes and seconds become 0
+ *
+ * @return static
+ */
+ public function startOfHour()
+ {
+ return $this->setTime($this->hour, 0, 0);
+ }
+
+ /**
+ * Modify to end of current hour, minutes and seconds become 59
+ *
+ * @return static
+ */
+ public function endOfHour()
+ {
+ return $this->modify("$this->hour:59:59.999999");
+ }
+
+ /**
+ * Modify to start of current minute, seconds become 0
+ *
+ * @return static
+ */
+ public function startOfMinute()
+ {
+ return $this->setTime($this->hour, $this->minute, 0);
+ }
+
+ /**
+ * Modify to end of current minute, seconds become 59
+ *
+ * @return static
+ */
+ public function endOfMinute()
+ {
+ return $this->modify("$this->hour:$this->minute:59.999999");
+ }
+
+ /**
+ * Modify to start of current minute, seconds become 0
+ *
+ * @return static
+ */
+ public function startOfSecond()
+ {
+ return $this->modify("$this->hour:$this->minute:$this->second.0");
+ }
+
+ /**
+ * Modify to end of current minute, seconds become 59
+ *
+ * @return static
+ */
+ public function endOfSecond()
+ {
+ return $this->modify("$this->hour:$this->minute:$this->second.999999");
+ }
+
+ /**
+ * Modify to midday, default to self::$midDayAt
+ *
+ * @return static
+ */
+ public function midDay()
+ {
+ return $this->setTime(self::$midDayAt, 0, 0);
+ }
+
/**
* Modify to the next occurrence of a given day of the week.
* If no dayOfWeek is provided, modify to the next occurrence
- * of the current day of the week. Use the supplied consts
+ * of the current day of the week. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
@@ -2398,10 +4938,69 @@ public function next($dayOfWeek = null)
return $this->startOfDay()->modify('next '.static::$days[$dayOfWeek]);
}
+ /**
+ * Go forward or backward to the next week- or weekend-day.
+ *
+ * @param bool $weekday
+ * @param bool $forward
+ *
+ * @return $this
+ */
+ private function nextOrPreviousDay($weekday = true, $forward = true)
+ {
+ $step = $forward ? 1 : -1;
+
+ do {
+ $this->addDay($step);
+ } while ($weekday ? $this->isWeekend() : $this->isWeekday());
+
+ return $this;
+ }
+
+ /**
+ * Go forward to the next weekday.
+ *
+ * @return $this
+ */
+ public function nextWeekday()
+ {
+ return $this->nextOrPreviousDay();
+ }
+
+ /**
+ * Go backward to the previous weekday.
+ *
+ * @return $this
+ */
+ public function previousWeekday()
+ {
+ return $this->nextOrPreviousDay(true, false);
+ }
+
+ /**
+ * Go forward to the next weekend day.
+ *
+ * @return $this
+ */
+ public function nextWeekendDay()
+ {
+ return $this->nextOrPreviousDay(false);
+ }
+
+ /**
+ * Go backward to the previous weekend day.
+ *
+ * @return $this
+ */
+ public function previousWeekendDay()
+ {
+ return $this->nextOrPreviousDay(false, false);
+ }
+
/**
* Modify to the previous occurrence of a given day of the week.
* If no dayOfWeek is provided, modify to the previous occurrence
- * of the current day of the week. Use the supplied consts
+ * of the current day of the week. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
@@ -2420,7 +5019,7 @@ public function previous($dayOfWeek = null)
/**
* Modify to the first occurrence of a given day of the week
* in the current month. If no dayOfWeek is provided, modify to the
- * first day of the current month. Use the supplied consts
+ * first day of the current month. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
@@ -2441,7 +5040,7 @@ public function firstOfMonth($dayOfWeek = null)
/**
* Modify to the last occurrence of a given day of the week
* in the current month. If no dayOfWeek is provided, modify to the
- * last day of the current month. Use the supplied consts
+ * last day of the current month. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int|null $dayOfWeek
@@ -2463,7 +5062,7 @@ public function lastOfMonth($dayOfWeek = null)
* Modify to the given occurrence of a given day of the week
* in the current month. If the calculated occurrence is outside the scope
* of the current month, then return false and no modifications are made.
- * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
+ * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int $nth
* @param int $dayOfWeek
@@ -2472,48 +5071,48 @@ public function lastOfMonth($dayOfWeek = null)
*/
public function nthOfMonth($nth, $dayOfWeek)
{
- $dt = $this->copy()->firstOfMonth();
- $check = $dt->format('Y-m');
- $dt->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
+ $date = $this->copy()->firstOfMonth();
+ $check = $date->format('Y-m');
+ $date->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
- return $dt->format('Y-m') === $check ? $this->modify($dt) : false;
+ return $date->format('Y-m') === $check ? $this->modify($date) : false;
}
/**
* Modify to the first occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
- * first day of the current quarter. Use the supplied consts
+ * first day of the current quarter. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
- * @param int|null $dayOfWeek
+ * @param int|null $dayOfWeek day of the week default null
*
* @return static
*/
public function firstOfQuarter($dayOfWeek = null)
{
- return $this->day(1)->month($this->quarter * 3 - 2)->firstOfMonth($dayOfWeek);
+ return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER - 2, 1)->firstOfMonth($dayOfWeek);
}
/**
* Modify to the last occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
- * last day of the current quarter. Use the supplied consts
+ * last day of the current quarter. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
- * @param int|null $dayOfWeek
+ * @param int|null $dayOfWeek day of the week default null
*
* @return static
*/
public function lastOfQuarter($dayOfWeek = null)
{
- return $this->day(1)->month($this->quarter * 3)->lastOfMonth($dayOfWeek);
+ return $this->setDate($this->year, $this->quarter * static::MONTHS_PER_QUARTER, 1)->lastOfMonth($dayOfWeek);
}
/**
* Modify to the given occurrence of a given day of the week
* in the current quarter. If the calculated occurrence is outside the scope
* of the current quarter, then return false and no modifications are made.
- * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
+ * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int $nth
* @param int $dayOfWeek
@@ -2522,21 +5121,21 @@ public function lastOfQuarter($dayOfWeek = null)
*/
public function nthOfQuarter($nth, $dayOfWeek)
{
- $dt = $this->copy()->day(1)->month($this->quarter * 3);
- $lastMonth = $dt->month;
- $year = $dt->year;
- $dt->firstOfQuarter()->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
+ $date = $this->copy()->day(1)->month($this->quarter * static::MONTHS_PER_QUARTER);
+ $lastMonth = $date->month;
+ $year = $date->year;
+ $date->firstOfQuarter()->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
- return ($lastMonth < $dt->month || $year !== $dt->year) ? false : $this->modify($dt);
+ return ($lastMonth < $date->month || $year !== $date->year) ? false : $this->modify($date);
}
/**
* Modify to the first occurrence of a given day of the week
* in the current year. If no dayOfWeek is provided, modify to the
- * first day of the current year. Use the supplied consts
+ * first day of the current year. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
- * @param int|null $dayOfWeek
+ * @param int|null $dayOfWeek day of the week default null
*
* @return static
*/
@@ -2548,10 +5147,10 @@ public function firstOfYear($dayOfWeek = null)
/**
* Modify to the last occurrence of a given day of the week
* in the current year. If no dayOfWeek is provided, modify to the
- * last day of the current year. Use the supplied consts
+ * last day of the current year. Use the supplied constants
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
- * @param int|null $dayOfWeek
+ * @param int|null $dayOfWeek day of the week default null
*
* @return static
*/
@@ -2564,7 +5163,7 @@ public function lastOfYear($dayOfWeek = null)
* Modify to the given occurrence of a given day of the week
* in the current year. If the calculated occurrence is outside the scope
* of the current year, then return false and no modifications are made.
- * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
+ * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
*
* @param int $nth
* @param int $dayOfWeek
@@ -2573,36 +5172,256 @@ public function lastOfYear($dayOfWeek = null)
*/
public function nthOfYear($nth, $dayOfWeek)
{
- $dt = $this->copy()->firstOfYear()->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
+ $date = $this->copy()->firstOfYear()->modify('+'.$nth.' '.static::$days[$dayOfWeek]);
- return $this->year === $dt->year ? $this->modify($dt) : false;
+ return $this->year === $date->year ? $this->modify($date) : false;
}
/**
* Modify the current instance to the average of a given instance (default now) and the current instance.
*
- * @param Carbon|null $dt
+ * @param \Carbon\Carbon|\DateTimeInterface|string|null $date
*
* @return static
*/
- public function average(Carbon $dt = null)
+ public function average($date = null)
{
- $dt = $dt ?: static::now($this->tz);
+ $date = $this->resolveCarbon($date);
+ $increment = $this->diffInRealSeconds($date, false) / 2;
+ $intIncrement = floor($increment);
+ $microIncrement = (int) (($date->micro - $this->micro) / 2 + 1000000 * ($increment - $intIncrement));
+ $micro = (int) ($this->micro + $microIncrement);
+ while ($micro >= 1000000) {
+ $micro -= 1000000;
+ $intIncrement++;
+ }
+ $this->addSeconds($intIncrement);
+
+ if (version_compare(PHP_VERSION, '7.1.8-dev', '>=')) {
+ $this->setTime($this->hour, $this->minute, $this->second, $micro);
+ }
- return $this->addSeconds((int) ($this->diffInSeconds($dt, false) / 2));
+ return $this;
}
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////// SERIALIZATION /////////////////////////
+ ///////////////////////////////////////////////////////////////////
+
/**
- * Check if its the birthday. Compares the date/month values of the two dates.
+ * Return a serialized string of the instance.
+ *
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize($this);
+ }
+
+ /**
+ * Create an instance from a serialized string.
+ *
+ * @param string $value
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return static
+ */
+ public static function fromSerialized($value)
+ {
+ $instance = @unserialize($value);
+
+ if (!$instance instanceof static) {
+ throw new InvalidArgumentException('Invalid serialized value.');
+ }
+
+ return $instance;
+ }
+
+ /**
+ * The __set_state handler.
+ *
+ * @param array $array
+ *
+ * @return static
+ */
+ public static function __set_state($array)
+ {
+ return static::instance(parent::__set_state($array));
+ }
+
+ /**
+ * Prepare the object for JSON serialization.
+ *
+ * @return array|string
+ */
+ public function jsonSerialize()
+ {
+ if (static::$serializer) {
+ return call_user_func(static::$serializer, $this);
+ }
+
+ $carbon = $this;
+
+ return call_user_func(function () use ($carbon) {
+ return get_object_vars($carbon);
+ });
+ }
+
+ /**
+ * JSON serialize all Carbon instances using the given callback.
+ *
+ * @param callable $callback
+ *
+ * @return void
+ */
+ public static function serializeUsing($callback)
+ {
+ static::$serializer = $callback;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////// MACRO /////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Register a custom macro.
+ *
+ * @param string $name
+ * @param object|callable $macro
+ *
+ * @return void
+ */
+ public static function macro($name, $macro)
+ {
+ static::$localMacros[$name] = $macro;
+ }
+
+ /**
+ * Remove all macros.
+ */
+ public static function resetMacros()
+ {
+ static::$localMacros = array();
+ }
+
+ /**
+ * Mix another object into the class.
+ *
+ * @param object $mixin
+ *
+ * @return void
+ */
+ public static function mixin($mixin)
+ {
+ $reflection = new \ReflectionClass($mixin);
+ $methods = $reflection->getMethods(
+ \ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED
+ );
+
+ foreach ($methods as $method) {
+ $method->setAccessible(true);
+
+ static::macro($method->name, $method->invoke($mixin));
+ }
+ }
+
+ /**
+ * Checks if macro is registered.
*
- * @param Carbon|null $dt The instance to compare with or null to use current day.
+ * @param string $name
*
* @return bool
*/
- public function isBirthday(Carbon $dt = null)
+ public static function hasMacro($name)
+ {
+ return isset(static::$localMacros[$name]);
+ }
+
+ /**
+ * Dynamically handle calls to the class.
+ *
+ * @param string $method
+ * @param array $parameters
+ *
+ * @throws \BadMethodCallException
+ *
+ * @return mixed
+ */
+ public static function __callStatic($method, $parameters)
+ {
+ if (!static::hasMacro($method)) {
+ throw new \BadMethodCallException("Method $method does not exist.");
+ }
+
+ if (static::$localMacros[$method] instanceof Closure && method_exists('Closure', 'bind')) {
+ return call_user_func_array(Closure::bind(static::$localMacros[$method], null, get_called_class()), $parameters);
+ }
+
+ return call_user_func_array(static::$localMacros[$method], $parameters);
+ }
+
+ /**
+ * Dynamically handle calls to the class.
+ *
+ * @param string $method
+ * @param array $parameters
+ *
+ * @throws \BadMethodCallException|\ReflectionException
+ *
+ * @return mixed
+ */
+ public function __call($method, $parameters)
+ {
+ if (!static::hasMacro($method)) {
+ throw new \BadMethodCallException("Method $method does not exist.");
+ }
+
+ $macro = static::$localMacros[$method];
+
+ $reflexion = new \ReflectionFunction($macro);
+ $reflectionParameters = $reflexion->getParameters();
+ $expectedCount = count($reflectionParameters);
+ $actualCount = count($parameters);
+ if ($expectedCount > $actualCount && $reflectionParameters[$expectedCount - 1]->name === 'self') {
+ for ($i = $actualCount; $i < $expectedCount - 1; $i++) {
+ $parameters[] = $reflectionParameters[$i]->getDefaultValue();
+ }
+ $parameters[] = $this;
+ }
+
+ if ($macro instanceof Closure && method_exists($macro, 'bindTo')) {
+ return call_user_func_array($macro->bindTo($this, get_class($this)), $parameters);
+ }
+
+ return call_user_func_array($macro, $parameters);
+ }
+
+ /**
+ * Show truthy properties on var_dump().
+ *
+ * @return array
+ */
+ public function __debugInfo()
+ {
+ return array_filter(get_object_vars($this), function ($var) {
+ return $var;
+ });
+ }
+
+ /**
+ * Cast the current instance into the given class.
+ *
+ * @param string $className The $className::instance() method will be called to cast the current object.
+ *
+ * @return object
+ */
+ public function cast($className)
{
- $dt = $dt ?: static::now($this->tz);
+ if (!method_exists($className, 'instance')) {
+ throw new \InvalidArgumentException("$className has not the instance() method needed to cast the date.");
+ }
- return $this->format('md') === $dt->format('md');
+ return $className::instance($this);
}
}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php b/application/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php
index 05f00a4..e8c6032 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php
@@ -11,15 +11,17 @@
namespace Carbon;
+use Closure;
use DateInterval;
use InvalidArgumentException;
-use Symfony\Component\Translation\Translator;
+use ReflectionClass;
+use ReflectionFunction;
+use ReflectionMethod;
use Symfony\Component\Translation\TranslatorInterface;
-use Symfony\Component\Translation\Loader\ArrayLoader;
/**
* A simple API extension for DateInterval.
- * The implemenation provides helpers to handle weeks but only days are saved.
+ * The implementation provides helpers to handle weeks but only days are saved.
* Weeks are calculated based on the total days of the current instance.
*
* @property int $years Total years of the current interval.
@@ -29,9 +31,16 @@
* @property int $hours Total hours of the current interval.
* @property int $minutes Total minutes of the current interval.
* @property int $seconds Total seconds of the current interval.
- *
- * @property-read integer $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7).
- * @property-read integer $daysExcludeWeeks alias of dayzExcludeWeeks
+ * @property-read int $dayzExcludeWeeks Total days remaining in the final week of the current instance (days % 7).
+ * @property-read int $daysExcludeWeeks alias of dayzExcludeWeeks
+ * @property-read float $totalYears Number of years equivalent to the interval.
+ * @property-read float $totalMonths Number of months equivalent to the interval.
+ * @property-read float $totalWeeks Number of weeks equivalent to the interval.
+ * @property-read float $totalDays Number of days equivalent to the interval.
+ * @property-read float $totalDayz Alias for totalDays.
+ * @property-read float $totalHours Number of hours equivalent to the interval.
+ * @property-read float $totalMinutes Number of minutes equivalent to the interval.
+ * @property-read float $totalSeconds Number of seconds equivalent to the interval.
*
* @method static CarbonInterval years($years = 1) Create instance specifying a number of years.
* @method static CarbonInterval year($years = 1) Alias for years()
@@ -48,21 +57,21 @@
* @method static CarbonInterval minute($minutes = 1) Alias for minutes()
* @method static CarbonInterval seconds($seconds = 1) Create instance specifying a number of seconds.
* @method static CarbonInterval second($seconds = 1) Alias for seconds()
- * @method CarbonInterval years() years($years = 1) Set the years portion of the current interval.
- * @method CarbonInterval year() year($years = 1) Alias for years().
- * @method CarbonInterval months() months($months = 1) Set the months portion of the current interval.
- * @method CarbonInterval month() month($months = 1) Alias for months().
- * @method CarbonInterval weeks() weeks($weeks = 1) Set the weeks portion of the current interval. Will overwrite dayz value.
- * @method CarbonInterval week() week($weeks = 1) Alias for weeks().
- * @method CarbonInterval days() days($days = 1) Set the days portion of the current interval.
- * @method CarbonInterval dayz() dayz($days = 1) Alias for days().
- * @method CarbonInterval day() day($days = 1) Alias for days().
- * @method CarbonInterval hours() hours($hours = 1) Set the hours portion of the current interval.
- * @method CarbonInterval hour() hour($hours = 1) Alias for hours().
- * @method CarbonInterval minutes() minutes($minutes = 1) Set the minutes portion of the current interval.
- * @method CarbonInterval minute() minute($minutes = 1) Alias for minutes().
- * @method CarbonInterval seconds() seconds($seconds = 1) Set the seconds portion of the current interval.
- * @method CarbonInterval second() second($seconds = 1) Alias for seconds().
+ * @method CarbonInterval years($years = 1) Set the years portion of the current interval.
+ * @method CarbonInterval year($years = 1) Alias for years().
+ * @method CarbonInterval months($months = 1) Set the months portion of the current interval.
+ * @method CarbonInterval month($months = 1) Alias for months().
+ * @method CarbonInterval weeks($weeks = 1) Set the weeks portion of the current interval. Will overwrite dayz value.
+ * @method CarbonInterval week($weeks = 1) Alias for weeks().
+ * @method CarbonInterval days($days = 1) Set the days portion of the current interval.
+ * @method CarbonInterval dayz($days = 1) Alias for days().
+ * @method CarbonInterval day($days = 1) Alias for days().
+ * @method CarbonInterval hours($hours = 1) Set the hours portion of the current interval.
+ * @method CarbonInterval hour($hours = 1) Alias for hours().
+ * @method CarbonInterval minutes($minutes = 1) Set the minutes portion of the current interval.
+ * @method CarbonInterval minute($minutes = 1) Alias for minutes().
+ * @method CarbonInterval seconds($seconds = 1) Set the seconds portion of the current interval.
+ * @method CarbonInterval second($seconds = 1) Alias for seconds().
*/
class CarbonInterval extends DateInterval
{
@@ -81,16 +90,81 @@ class CarbonInterval extends DateInterval
/**
* A translator to ... er ... translate stuff
*
- * @var TranslatorInterface
+ * @var \Symfony\Component\Translation\TranslatorInterface
*/
protected static $translator;
+ /**
+ * @var array|null
+ */
+ protected static $cascadeFactors;
+
+ /**
+ * @var array|null
+ */
+ private static $flipCascadeFactors;
+
+ /**
+ * The registered macros.
+ *
+ * @var array
+ */
+ protected static $macros = array();
+
/**
* Before PHP 5.4.20/5.5.4 instead of FALSE days will be set to -99999 when the interval instance
- * was created by DateTime:diff().
+ * was created by DateTime::diff().
*/
const PHP_DAYS_FALSE = -99999;
+ /**
+ * Mapping of units and factors for cascading.
+ *
+ * Should only be modified by changing the factors or referenced constants.
+ *
+ * @return array
+ */
+ public static function getCascadeFactors()
+ {
+ return static::$cascadeFactors ?: array(
+ 'minutes' => array(Carbon::SECONDS_PER_MINUTE, 'seconds'),
+ 'hours' => array(Carbon::MINUTES_PER_HOUR, 'minutes'),
+ 'dayz' => array(Carbon::HOURS_PER_DAY, 'hours'),
+ 'months' => array(Carbon::DAYS_PER_WEEK * Carbon::WEEKS_PER_MONTH, 'dayz'),
+ 'years' => array(Carbon::MONTHS_PER_YEAR, 'months'),
+ );
+ }
+
+ private static function standardizeUnit($unit)
+ {
+ $unit = rtrim($unit, 'sz').'s';
+
+ return $unit === 'days' ? 'dayz' : $unit;
+ }
+
+ private static function getFlipCascadeFactors()
+ {
+ if (!self::$flipCascadeFactors) {
+ self::$flipCascadeFactors = array();
+ foreach (static::getCascadeFactors() as $to => $tuple) {
+ list($factor, $from) = $tuple;
+
+ self::$flipCascadeFactors[self::standardizeUnit($from)] = array(self::standardizeUnit($to), $factor);
+ }
+ }
+
+ return self::$flipCascadeFactors;
+ }
+
+ /**
+ * @param array $cascadeFactors
+ */
+ public static function setCascadeFactors(array $cascadeFactors)
+ {
+ self::$flipCascadeFactors = null;
+ static::$cascadeFactors = $cascadeFactors;
+ }
+
/**
* Determine if the interval was created via DateTime:diff() or not.
*
@@ -120,32 +194,99 @@ private static function wasCreatedFromDiff(DateInterval $interval)
*/
public function __construct($years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null)
{
- $spec = static::PERIOD_PREFIX;
+ $spec = $years;
- $spec .= $years > 0 ? $years.static::PERIOD_YEARS : '';
- $spec .= $months > 0 ? $months.static::PERIOD_MONTHS : '';
+ if (!is_string($spec) || floatval($years) || preg_match('/^[0-9.]/', $years)) {
+ $spec = static::PERIOD_PREFIX;
- $specDays = 0;
- $specDays += $weeks > 0 ? $weeks * Carbon::DAYS_PER_WEEK : 0;
- $specDays += $days > 0 ? $days : 0;
+ $spec .= $years > 0 ? $years.static::PERIOD_YEARS : '';
+ $spec .= $months > 0 ? $months.static::PERIOD_MONTHS : '';
- $spec .= $specDays > 0 ? $specDays.static::PERIOD_DAYS : '';
+ $specDays = 0;
+ $specDays += $weeks > 0 ? $weeks * static::getDaysPerWeek() : 0;
+ $specDays += $days > 0 ? $days : 0;
- if ($hours > 0 || $minutes > 0 || $seconds > 0) {
- $spec .= static::PERIOD_TIME_PREFIX;
- $spec .= $hours > 0 ? $hours.static::PERIOD_HOURS : '';
- $spec .= $minutes > 0 ? $minutes.static::PERIOD_MINUTES : '';
- $spec .= $seconds > 0 ? $seconds.static::PERIOD_SECONDS : '';
- }
+ $spec .= $specDays > 0 ? $specDays.static::PERIOD_DAYS : '';
+
+ if ($hours > 0 || $minutes > 0 || $seconds > 0) {
+ $spec .= static::PERIOD_TIME_PREFIX;
+ $spec .= $hours > 0 ? $hours.static::PERIOD_HOURS : '';
+ $spec .= $minutes > 0 ? $minutes.static::PERIOD_MINUTES : '';
+ $spec .= $seconds > 0 ? $seconds.static::PERIOD_SECONDS : '';
+ }
- if ($spec === static::PERIOD_PREFIX) {
- // Allow the zero interval.
- $spec .= '0'.static::PERIOD_YEARS;
+ if ($spec === static::PERIOD_PREFIX) {
+ // Allow the zero interval.
+ $spec .= '0'.static::PERIOD_YEARS;
+ }
}
parent::__construct($spec);
}
+ /**
+ * Returns the factor for a given source-to-target couple.
+ *
+ * @param string $source
+ * @param string $target
+ *
+ * @return int|null
+ */
+ public static function getFactor($source, $target)
+ {
+ $source = self::standardizeUnit($source);
+ $target = self::standardizeUnit($target);
+ $factors = static::getFlipCascadeFactors();
+ if (isset($factors[$source])) {
+ list($to, $factor) = $factors[$source];
+ if ($to === $target) {
+ return $factor;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns current config for days per week.
+ *
+ * @return int
+ */
+ public static function getDaysPerWeek()
+ {
+ return static::getFactor('dayz', 'weeks') ?: Carbon::DAYS_PER_WEEK;
+ }
+
+ /**
+ * Returns current config for hours per day.
+ *
+ * @return int
+ */
+ public static function getHoursPerDay()
+ {
+ return static::getFactor('hours', 'dayz') ?: Carbon::HOURS_PER_DAY;
+ }
+
+ /**
+ * Returns current config for minutes per hour.
+ *
+ * @return int
+ */
+ public static function getMinutesPerHours()
+ {
+ return static::getFactor('minutes', 'hours') ?: Carbon::MINUTES_PER_HOUR;
+ }
+
+ /**
+ * Returns current config for seconds per minute.
+ *
+ * @return int
+ */
+ public static function getSecondsPerMinutes()
+ {
+ return static::getFactor('seconds', 'minutes') ?: Carbon::SECONDS_PER_MINUTE;
+ }
+
/**
* Create a new CarbonInterval instance from specific values.
* This is an alias for the constructor that allows better fluent
@@ -167,6 +308,19 @@ public static function create($years = 1, $months = null, $weeks = null, $days =
return new static($years, $months, $weeks, $days, $hours, $minutes, $seconds);
}
+ /**
+ * Get a copy of the instance.
+ *
+ * @return static
+ */
+ public function copy()
+ {
+ $date = new static($this->spec());
+ $date->invert = $this->invert;
+
+ return $date;
+ }
+
/**
* Provide static helpers to create instances. Allows CarbonInterval::years(3).
*
@@ -212,6 +366,123 @@ public static function __callStatic($name, $args)
case 'second':
return new static(null, null, null, null, null, null, $arg);
}
+
+ if (static::hasMacro($name)) {
+ return call_user_func_array(
+ array(new static(0), $name), $args
+ );
+ }
+ }
+
+ /**
+ * Creates a CarbonInterval from string.
+ *
+ * Format:
+ *
+ * Suffix | Unit | Example | DateInterval expression
+ * -------|---------|---------|------------------------
+ * y | years | 1y | P1Y
+ * mo | months | 3mo | P3M
+ * w | weeks | 2w | P2W
+ * d | days | 28d | P28D
+ * h | hours | 4h | PT4H
+ * m | minutes | 12m | PT12M
+ * s | seconds | 59s | PT59S
+ *
+ * e. g. `1w 3d 4h 32m 23s` is converted to 10 days 4 hours 32 minutes and 23 seconds.
+ *
+ * Special cases:
+ * - An empty string will return a zero interval
+ * - Fractions are allowed for weeks, days, hours and minutes and will be converted
+ * and rounded to the next smaller value (caution: 0.5w = 4d)
+ *
+ * @param string $intervalDefinition
+ *
+ * @return static
+ */
+ public static function fromString($intervalDefinition)
+ {
+ if (empty($intervalDefinition)) {
+ return new static(0);
+ }
+
+ $years = 0;
+ $months = 0;
+ $weeks = 0;
+ $days = 0;
+ $hours = 0;
+ $minutes = 0;
+ $seconds = 0;
+
+ $pattern = '/(\d+(?:\.\d+)?)\h*([^\d\h]*)/i';
+ preg_match_all($pattern, $intervalDefinition, $parts, PREG_SET_ORDER);
+ while ($match = array_shift($parts)) {
+ list($part, $value, $unit) = $match;
+ $intValue = intval($value);
+ $fraction = floatval($value) - $intValue;
+ switch (strtolower($unit)) {
+ case 'year':
+ case 'years':
+ case 'y':
+ $years += $intValue;
+ break;
+
+ case 'month':
+ case 'months':
+ case 'mo':
+ $months += $intValue;
+ break;
+
+ case 'week':
+ case 'weeks':
+ case 'w':
+ $weeks += $intValue;
+ if ($fraction) {
+ $parts[] = array(null, $fraction * static::getDaysPerWeek(), 'd');
+ }
+ break;
+
+ case 'day':
+ case 'days':
+ case 'd':
+ $days += $intValue;
+ if ($fraction) {
+ $parts[] = array(null, $fraction * static::getHoursPerDay(), 'h');
+ }
+ break;
+
+ case 'hour':
+ case 'hours':
+ case 'h':
+ $hours += $intValue;
+ if ($fraction) {
+ $parts[] = array(null, $fraction * static::getMinutesPerHours(), 'm');
+ }
+ break;
+
+ case 'minute':
+ case 'minutes':
+ case 'm':
+ $minutes += $intValue;
+ if ($fraction) {
+ $seconds += round($fraction * static::getSecondsPerMinutes());
+ }
+ break;
+
+ case 'second':
+ case 'seconds':
+ case 's':
+ $seconds += $intValue;
+ break;
+
+ default:
+ throw new InvalidArgumentException(
+ sprintf('Invalid part %s in definition %s', $part, $intervalDefinition)
+ );
+ }
+ }
+
+ return new static($years, $months, $weeks, $days, $hours, $minutes, $seconds);
}
/**
@@ -219,49 +490,82 @@ public static function __callStatic($name, $args)
* DateInterval objects created from DateTime::diff() as you can't externally
* set the $days field.
*
- * @param DateInterval $di
+ * Pass false as second argument to get a microseconds-precise interval. Else
+ * microseconds in the original interval will not be kept.
*
- * @throws InvalidArgumentException
+ * @param DateInterval $di
+ * @param bool $trimMicroseconds (true by default)
*
* @return static
*/
- public static function instance(DateInterval $di)
+ public static function instance(DateInterval $di, $trimMicroseconds = true)
{
- if (static::wasCreatedFromDiff($di)) {
- throw new InvalidArgumentException("Can not instance a DateInterval object created from DateTime::diff().");
+ $microseconds = $trimMicroseconds || version_compare(PHP_VERSION, '7.1.0-dev', '<') ? 0 : $di->f;
+ $instance = new static(static::getDateIntervalSpec($di));
+ if ($microseconds) {
+ $instance->f = $microseconds;
}
-
- $instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s);
$instance->invert = $di->invert;
- $instance->days = $di->days;
+ foreach (array('y', 'm', 'd', 'h', 'i', 's') as $unit) {
+ if ($di->$unit < 0) {
+ $instance->$unit *= -1;
+ }
+ }
return $instance;
}
+ /**
+ * Make a CarbonInterval instance from given variable if possible.
+ *
+ * Always return a new instance. Parse only strings and only these likely to be intervals (skip dates
+ * and recurrences). Throw an exception for invalid format, but otherwise return null.
+ *
+ * @param mixed $var
+ *
+ * @return static|null
+ */
+ public static function make($var)
+ {
+ if ($var instanceof DateInterval) {
+ return static::instance($var);
+ }
+
+ if (is_string($var)) {
+ $var = trim($var);
+
+ if (substr($var, 0, 1) === 'P') {
+ return new static($var);
+ }
+
+ if (preg_match('/^(?:\h*\d+(?:\.\d+)?\h*[a-z]+)+$/i', $var)) {
+ return static::fromString($var);
+ }
+ }
+ }
+
///////////////////////////////////////////////////////////////////
/////////////////////// LOCALIZATION //////////////////////////////
///////////////////////////////////////////////////////////////////
/**
- * Intialize the translator instance if necessary.
+ * Initialize the translator instance if necessary.
*
- * @return TranslatorInterface
+ * @return \Symfony\Component\Translation\TranslatorInterface
*/
protected static function translator()
{
if (static::$translator === null) {
- static::$translator = new Translator('en');
- static::$translator->addLoader('array', new ArrayLoader());
- static::setLocale('en');
+ static::$translator = Translator::get();
}
return static::$translator;
}
/**
- * Get the translator instance in use
+ * Get the translator instance in use.
*
- * @return TranslatorInterface
+ * @return \Symfony\Component\Translation\TranslatorInterface
*/
public static function getTranslator()
{
@@ -269,7 +573,7 @@ public static function getTranslator()
}
/**
- * Set the translator instance to use
+ * Set the translator instance to use.
*
* @param TranslatorInterface $translator
*/
@@ -279,7 +583,7 @@ public static function setTranslator(TranslatorInterface $translator)
}
/**
- * Get the current translator locale
+ * Get the current translator locale.
*
* @return string
*/
@@ -289,16 +593,13 @@ public static function getLocale()
}
/**
- * Set the current translator locale
+ * Set the current translator locale.
*
* @param string $locale
*/
public static function setLocale($locale)
{
- static::translator()->setLocale($locale);
-
- // Ensure the locale has been loaded.
- static::translator()->addResource('array', require __DIR__.'/Lang/'.$locale.'.php', $locale);
+ return static::translator()->setLocale($locale) !== false;
}
///////////////////////////////////////////////////////////////////
@@ -306,16 +607,20 @@ public static function setLocale($locale)
///////////////////////////////////////////////////////////////////
/**
- * Get a part of the CarbonInterval object
+ * Get a part of the CarbonInterval object.
*
* @param string $name
*
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
*
- * @return int
+ * @return int|float
*/
public function __get($name)
{
+ if (substr($name, 0, 5) === 'total') {
+ return $this->total(substr($name, 5));
+ }
+
switch ($name) {
case 'years':
return $this->y;
@@ -336,11 +641,11 @@ public function __get($name)
return $this->s;
case 'weeks':
- return (int)floor($this->d / Carbon::DAYS_PER_WEEK);
+ return (int) floor($this->d / static::getDaysPerWeek());
case 'daysExcludeWeeks':
case 'dayzExcludeWeeks':
- return $this->d % Carbon::DAYS_PER_WEEK;
+ return $this->d % static::getDaysPerWeek();
default:
throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name));
@@ -348,12 +653,12 @@ public function __get($name)
}
/**
- * Set a part of the CarbonInterval object
+ * Set a part of the CarbonInterval object.
*
* @param string $name
* @param int $val
*
- * @throws InvalidArgumentException
+ * @throws \InvalidArgumentException
*/
public function __set($name, $val)
{
@@ -367,7 +672,7 @@ public function __set($name, $val)
break;
case 'weeks':
- $this->d = $val * Carbon::DAYS_PER_WEEK;
+ $this->d = $val * static::getDaysPerWeek();
break;
case 'dayz':
@@ -398,11 +703,102 @@ public function __set($name, $val)
*/
public function weeksAndDays($weeks, $days)
{
- $this->dayz = ($weeks * Carbon::DAYS_PER_WEEK) + $days;
+ $this->dayz = ($weeks * static::getDaysPerWeek()) + $days;
return $this;
}
+ /**
+ * Register a custom macro.
+ *
+ * @param string $name
+ * @param object|callable $macro
+ *
+ * @return void
+ */
+ public static function macro($name, $macro)
+ {
+ static::$macros[$name] = $macro;
+ }
+
+ /**
+ * Remove all macros.
+ */
+ public static function resetMacros()
+ {
+ static::$macros = array();
+ }
+
+ /**
+ * Register macros from a mixin object.
+ *
+ * @param object $mixin
+ *
+ * @throws \ReflectionException
+ *
+ * @return void
+ */
+ public static function mixin($mixin)
+ {
+ $reflection = new ReflectionClass($mixin);
+
+ $methods = $reflection->getMethods(
+ ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
+ );
+
+ foreach ($methods as $method) {
+ $method->setAccessible(true);
+
+ static::macro($method->name, $method->invoke($mixin));
+ }
+ }
+
+ /**
+ * Check if macro is registered.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public static function hasMacro($name)
+ {
+ return isset(static::$macros[$name]);
+ }
+
+ /**
+ * Call given macro.
+ *
+ * @param string $name
+ * @param array $parameters
+ *
+ * @return mixed
+ */
+ protected function callMacro($name, $parameters)
+ {
+ $macro = static::$macros[$name];
+
+ $reflection = new ReflectionFunction($macro);
+
+ $reflectionParameters = $reflection->getParameters();
+
+ $expectedCount = count($reflectionParameters);
+ $actualCount = count($parameters);
+
+ if ($expectedCount > $actualCount && $reflectionParameters[$expectedCount - 1]->name === 'self') {
+ for ($i = $actualCount; $i < $expectedCount - 1; $i++) {
+ $parameters[] = $reflectionParameters[$i]->getDefaultValue();
+ }
+
+ $parameters[] = $this;
+ }
+
+ if ($macro instanceof Closure && method_exists($macro, 'bindTo')) {
+ $macro = $macro->bindTo($this, get_class($this));
+ }
+
+ return call_user_func_array($macro, $parameters);
+ }
+
/**
* Allow fluent calls on the setters... CarbonInterval::years(3)->months(5)->day().
*
@@ -416,6 +812,10 @@ public function weeksAndDays($weeks, $days)
*/
public function __call($name, $args)
{
+ if (static::hasMacro($name)) {
+ return $this->callMacro($name, $args);
+ }
+
$arg = count($args) === 0 ? 1 : $args[0];
switch ($name) {
@@ -431,7 +831,7 @@ public function __call($name, $args)
case 'weeks':
case 'week':
- $this->dayz = $arg * Carbon::DAYS_PER_WEEK;
+ $this->dayz = $arg * static::getDaysPerWeek();
break;
case 'days':
@@ -462,24 +862,27 @@ public function __call($name, $args)
/**
* Get the current interval in a human readable format in the current locale.
*
+ * @param bool $short (false by default), returns short units if true
+ *
* @return string
*/
- public function forHumans()
+ public function forHumans($short = false)
{
$periods = array(
- 'year' => $this->years,
- 'month' => $this->months,
- 'week' => $this->weeks,
- 'day' => $this->daysExcludeWeeks,
- 'hour' => $this->hours,
- 'minute' => $this->minutes,
- 'second' => $this->seconds,
+ 'year' => array('y', $this->years),
+ 'month' => array('m', $this->months),
+ 'week' => array('w', $this->weeks),
+ 'day' => array('d', $this->daysExcludeWeeks),
+ 'hour' => array('h', $this->hours),
+ 'minute' => array('min', $this->minutes),
+ 'second' => array('s', $this->seconds),
);
$parts = array();
- foreach ($periods as $unit => $count) {
+ foreach ($periods as $unit => $options) {
+ list($shortUnit, $count) = $options;
if ($count > 0) {
- array_push($parts, static::translator()->transChoice($unit, $count, array(':count' => $count)));
+ $parts[] = static::translator()->transChoice($short ? $shortUnit : $unit, $count, array(':count' => $count));
}
}
@@ -497,7 +900,31 @@ public function __toString()
}
/**
- * Add the passed interval to the current instance
+ * Convert the interval to a CarbonPeriod.
+ *
+ * @return CarbonPeriod
+ */
+ public function toPeriod()
+ {
+ return CarbonPeriod::createFromArray(
+ array_merge(array($this), func_get_args())
+ );
+ }
+
+ /**
+ * Invert the interval.
+ *
+ * @return $this
+ */
+ public function invert()
+ {
+ $this->invert = $this->invert ? 0 : 1;
+
+ return $this;
+ }
+
+ /**
+ * Add the passed interval to the current instance.
*
* @param DateInterval $interval
*
@@ -505,19 +932,232 @@ public function __toString()
*/
public function add(DateInterval $interval)
{
- $sign = $interval->invert === 1 ? -1 : 1;
+ $sign = ($this->invert === 1) !== ($interval->invert === 1) ? -1 : 1;
if (static::wasCreatedFromDiff($interval)) {
- $this->dayz = $this->dayz + $interval->days * $sign;
+ $this->dayz += $interval->days * $sign;
} else {
- $this->years = $this->years + $interval->y * $sign;
- $this->months = $this->months + $interval->m * $sign;
- $this->dayz = $this->dayz + $interval->d * $sign;
- $this->hours = $this->hours + $interval->h * $sign;
- $this->minutes = $this->minutes + $interval->i * $sign;
- $this->seconds = $this->seconds + $interval->s * $sign;
+ $this->years += $interval->y * $sign;
+ $this->months += $interval->m * $sign;
+ $this->dayz += $interval->d * $sign;
+ $this->hours += $interval->h * $sign;
+ $this->minutes += $interval->i * $sign;
+ $this->seconds += $interval->s * $sign;
+ }
+
+ if (($this->years || $this->months || $this->dayz || $this->hours || $this->minutes || $this->seconds) &&
+ $this->years <= 0 && $this->months <= 0 && $this->dayz <= 0 && $this->hours <= 0 && $this->minutes <= 0 && $this->seconds <= 0
+ ) {
+ $this->years *= -1;
+ $this->months *= -1;
+ $this->dayz *= -1;
+ $this->hours *= -1;
+ $this->minutes *= -1;
+ $this->seconds *= -1;
+ $this->invert();
}
return $this;
}
+
+ /**
+ * Multiply current instance given number of times
+ *
+ * @param float $factor
+ *
+ * @return $this
+ */
+ public function times($factor)
+ {
+ if ($factor < 0) {
+ $this->invert = $this->invert ? 0 : 1;
+ $factor = -$factor;
+ }
+
+ $this->years = (int) round($this->years * $factor);
+ $this->months = (int) round($this->months * $factor);
+ $this->dayz = (int) round($this->dayz * $factor);
+ $this->hours = (int) round($this->hours * $factor);
+ $this->minutes = (int) round($this->minutes * $factor);
+ $this->seconds = (int) round($this->seconds * $factor);
+
+ return $this;
+ }
+
+ /**
+ * Get the interval_spec string of a date interval.
+ *
+ * @param DateInterval $interval
+ *
+ * @return string
+ */
+ public static function getDateIntervalSpec(DateInterval $interval)
+ {
+ $date = array_filter(array(
+ static::PERIOD_YEARS => abs($interval->y),
+ static::PERIOD_MONTHS => abs($interval->m),
+ static::PERIOD_DAYS => abs($interval->d),
+ ));
+
+ $time = array_filter(array(
+ static::PERIOD_HOURS => abs($interval->h),
+ static::PERIOD_MINUTES => abs($interval->i),
+ static::PERIOD_SECONDS => abs($interval->s),
+ ));
+
+ $specString = static::PERIOD_PREFIX;
+
+ foreach ($date as $key => $value) {
+ $specString .= $value.$key;
+ }
+
+ if (count($time) > 0) {
+ $specString .= static::PERIOD_TIME_PREFIX;
+ foreach ($time as $key => $value) {
+ $specString .= $value.$key;
+ }
+ }
+
+ return $specString === static::PERIOD_PREFIX ? 'PT0S' : $specString;
+ }
+
+ /**
+ * Get the interval_spec string.
+ *
+ * @return string
+ */
+ public function spec()
+ {
+ return static::getDateIntervalSpec($this);
+ }
+
+ /**
+ * Comparing 2 date intervals.
+ *
+ * @param DateInterval $a
+ * @param DateInterval $b
+ *
+ * @return int
+ */
+ public static function compareDateIntervals(DateInterval $a, DateInterval $b)
+ {
+ $current = Carbon::now();
+ $passed = $current->copy()->add($b);
+ $current->add($a);
+
+ if ($current < $passed) {
+ return -1;
+ }
+ if ($current > $passed) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ /**
+ * Comparing with passed interval.
+ *
+ * @param DateInterval $interval
+ *
+ * @return int
+ */
+ public function compare(DateInterval $interval)
+ {
+ return static::compareDateIntervals($this, $interval);
+ }
+
+ /**
+ * Convert overflowed values into bigger units.
+ *
+ * @return $this
+ */
+ public function cascade()
+ {
+ foreach (static::getFlipCascadeFactors() as $source => $cascade) {
+ list($target, $factor) = $cascade;
+
+ if ($source === 'dayz' && $target === 'weeks') {
+ continue;
+ }
+
+ $value = $this->$source;
+ $this->$source = $modulo = $value % $factor;
+ $this->$target += ($value - $modulo) / $factor;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get amount of given unit equivalent to the interval.
+ *
+ * @param string $unit
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return float
+ */
+ public function total($unit)
+ {
+ $realUnit = $unit = strtolower($unit);
+
+ if (in_array($unit, array('days', 'weeks'))) {
+ $realUnit = 'dayz';
+ } elseif (!in_array($unit, array('seconds', 'minutes', 'hours', 'dayz', 'months', 'years'))) {
+ throw new InvalidArgumentException("Unknown unit '$unit'.");
+ }
+
+ $result = 0;
+ $cumulativeFactor = 0;
+ $unitFound = false;
+
+ foreach (static::getFlipCascadeFactors() as $source => $cascade) {
+ list($target, $factor) = $cascade;
+
+ if ($source === $realUnit) {
+ $unitFound = true;
+ $result += $this->$source;
+ $cumulativeFactor = 1;
+ }
+
+ if ($factor === false) {
+ if ($unitFound) {
+ break;
+ }
+
+ $result = 0;
+ $cumulativeFactor = 0;
+
+ continue;
+ }
+
+ if ($target === $realUnit) {
+ $unitFound = true;
+ }
+
+ if ($cumulativeFactor) {
+ $cumulativeFactor *= $factor;
+ $result += $this->$target * $cumulativeFactor;
+
+ continue;
+ }
+
+ $result = ($result + $this->$source) / $factor;
+ }
+
+ if (isset($target) && !$cumulativeFactor) {
+ $result += $this->$target;
+ }
+
+ if (!$unitFound) {
+ throw new \InvalidArgumentException("Unit $unit have no configuration to get total from other units.");
+ }
+
+ if ($unit === 'weeks') {
+ return $result / static::getDaysPerWeek();
+ }
+
+ return $result;
+ }
}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php b/application/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php
new file mode 100644
index 0000000..808e9d6
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php
@@ -0,0 +1,1453 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Carbon;
+
+use BadMethodCallException;
+use Closure;
+use Countable;
+use DateInterval;
+use DateTime;
+use DateTimeInterface;
+use InvalidArgumentException;
+use Iterator;
+use ReflectionClass;
+use ReflectionFunction;
+use ReflectionMethod;
+use RuntimeException;
+
+/**
+ * Substitution of DatePeriod with some modifications and many more features.
+ * Fully compatible with PHP 5.3+!
+ *
+ * @method static CarbonPeriod start($date, $inclusive = null) Create instance specifying start date.
+ * @method static CarbonPeriod since($date, $inclusive = null) Alias for start().
+ * @method static CarbonPeriod sinceNow($inclusive = null) Create instance with start date set to now.
+ * @method static CarbonPeriod end($date = null, $inclusive = null) Create instance specifying end date.
+ * @method static CarbonPeriod until($date = null, $inclusive = null) Alias for end().
+ * @method static CarbonPeriod untilNow($inclusive = null) Create instance with end date set to now.
+ * @method static CarbonPeriod dates($start, $end = null) Create instance with start and end date.
+ * @method static CarbonPeriod between($start, $end = null) Create instance with start and end date.
+ * @method static CarbonPeriod recurrences($recurrences = null) Create instance with maximum number of recurrences.
+ * @method static CarbonPeriod times($recurrences = null) Alias for recurrences().
+ * @method static CarbonPeriod options($options = null) Create instance with options.
+ * @method static CarbonPeriod toggle($options, $state = null) Create instance with options toggled on or off.
+ * @method static CarbonPeriod filter($callback, $name = null) Create instance with filter added to the stack.
+ * @method static CarbonPeriod push($callback, $name = null) Alias for filter().
+ * @method static CarbonPeriod prepend($callback, $name = null) Create instance with filter prepened to the stack.
+ * @method static CarbonPeriod filters(array $filters) Create instance with filters stack.
+ * @method static CarbonPeriod interval($interval) Create instance with given date interval.
+ * @method static CarbonPeriod each($interval) Create instance with given date interval.
+ * @method static CarbonPeriod every($interval) Create instance with given date interval.
+ * @method static CarbonPeriod step($interval) Create instance with given date interval.
+ * @method static CarbonPeriod stepBy($interval) Create instance with given date interval.
+ * @method static CarbonPeriod invert() Create instance with inverted date interval.
+ * @method static CarbonPeriod years($years = 1) Create instance specifying a number of years for date interval.
+ * @method static CarbonPeriod year($years = 1) Alias for years().
+ * @method static CarbonPeriod months($months = 1) Create instance specifying a number of months for date interval.
+ * @method static CarbonPeriod month($months = 1) Alias for months().
+ * @method static CarbonPeriod weeks($weeks = 1) Create instance specifying a number of weeks for date interval.
+ * @method static CarbonPeriod week($weeks = 1) Alias for weeks().
+ * @method static CarbonPeriod days($days = 1) Create instance specifying a number of days for date interval.
+ * @method static CarbonPeriod dayz($days = 1) Alias for days().
+ * @method static CarbonPeriod day($days = 1) Alias for days().
+ * @method static CarbonPeriod hours($hours = 1) Create instance specifying a number of hours for date interval.
+ * @method static CarbonPeriod hour($hours = 1) Alias for hours().
+ * @method static CarbonPeriod minutes($minutes = 1) Create instance specifying a number of minutes for date interval.
+ * @method static CarbonPeriod minute($minutes = 1) Alias for minutes().
+ * @method static CarbonPeriod seconds($seconds = 1) Create instance specifying a number of seconds for date interval.
+ * @method static CarbonPeriod second($seconds = 1) Alias for seconds().
+ * @method CarbonPeriod start($date, $inclusive = null) Change the period start date.
+ * @method CarbonPeriod since($date, $inclusive = null) Alias for start().
+ * @method CarbonPeriod sinceNow($inclusive = null) Change the period start date to now.
+ * @method CarbonPeriod end($date = null, $inclusive = null) Change the period end date.
+ * @method CarbonPeriod until($date = null, $inclusive = null) Alias for end().
+ * @method CarbonPeriod untilNow($inclusive = null) Change the period end date to now.
+ * @method CarbonPeriod dates($start, $end = null) Change the period start and end date.
+ * @method CarbonPeriod recurrences($recurrences = null) Change the maximum number of recurrences.
+ * @method CarbonPeriod times($recurrences = null) Alias for recurrences().
+ * @method CarbonPeriod options($options = null) Change the period options.
+ * @method CarbonPeriod toggle($options, $state = null) Toggle given options on or off.
+ * @method CarbonPeriod filter($callback, $name = null) Add a filter to the stack.
+ * @method CarbonPeriod push($callback, $name = null) Alias for filter().
+ * @method CarbonPeriod prepend($callback, $name = null) Prepend a filter to the stack.
+ * @method CarbonPeriod filters(array $filters = array()) Set filters stack.
+ * @method CarbonPeriod interval($interval) Change the period date interval.
+ * @method CarbonPeriod invert() Invert the period date interval.
+ * @method CarbonPeriod years($years = 1) Set the years portion of the date interval.
+ * @method CarbonPeriod year($years = 1) Alias for years().
+ * @method CarbonPeriod months($months = 1) Set the months portion of the date interval.
+ * @method CarbonPeriod month($months = 1) Alias for months().
+ * @method CarbonPeriod weeks($weeks = 1) Set the weeks portion of the date interval.
+ * @method CarbonPeriod week($weeks = 1) Alias for weeks().
+ * @method CarbonPeriod days($days = 1) Set the days portion of the date interval.
+ * @method CarbonPeriod dayz($days = 1) Alias for days().
+ * @method CarbonPeriod day($days = 1) Alias for days().
+ * @method CarbonPeriod hours($hours = 1) Set the hours portion of the date interval.
+ * @method CarbonPeriod hour($hours = 1) Alias for hours().
+ * @method CarbonPeriod minutes($minutes = 1) Set the minutes portion of the date interval.
+ * @method CarbonPeriod minute($minutes = 1) Alias for minutes().
+ * @method CarbonPeriod seconds($seconds = 1) Set the seconds portion of the date interval.
+ * @method CarbonPeriod second($seconds = 1) Alias for seconds().
+ */
+class CarbonPeriod implements Iterator, Countable
+{
+ /**
+ * Built-in filters.
+ *
+ * @var string
+ */
+ const RECURRENCES_FILTER = 'Carbon\CarbonPeriod::filterRecurrences';
+ const END_DATE_FILTER = 'Carbon\CarbonPeriod::filterEndDate';
+
+ /**
+ * Special value which can be returned by filters to end iteration. Also a filter.
+ *
+ * @var string
+ */
+ const END_ITERATION = 'Carbon\CarbonPeriod::endIteration';
+
+ /**
+ * Available options.
+ *
+ * @var int
+ */
+ const EXCLUDE_START_DATE = 1;
+ const EXCLUDE_END_DATE = 2;
+
+ /**
+ * Number of maximum attempts before giving up on finding next valid date.
+ *
+ * @var int
+ */
+ const NEXT_MAX_ATTEMPTS = 1000;
+
+ /**
+ * The registered macros.
+ *
+ * @var array
+ */
+ protected static $macros = array();
+
+ /**
+ * Underlying date interval instance. Always present, one day by default.
+ *
+ * @var CarbonInterval
+ */
+ protected $dateInterval;
+
+ /**
+ * Whether current date interval was set by default.
+ *
+ * @var bool
+ */
+ protected $isDefaultInterval;
+
+ /**
+ * The filters stack.
+ *
+ * @var array
+ */
+ protected $filters = array();
+
+ /**
+ * Period start date. Applied on rewind. Always present, now by default.
+ *
+ * @var Carbon
+ */
+ protected $startDate;
+
+ /**
+ * Period end date. For inverted interval should be before the start date. Applied via a filter.
+ *
+ * @var Carbon|null
+ */
+ protected $endDate;
+
+ /**
+ * Limit for number of recurrences. Applied via a filter.
+ *
+ * @var int|null
+ */
+ protected $recurrences;
+
+ /**
+ * Iteration options.
+ *
+ * @var int
+ */
+ protected $options;
+
+ /**
+ * Index of current date. Always sequential, even if some dates are skipped by filters.
+ * Equal to null only before the first iteration.
+ *
+ * @var int
+ */
+ protected $key;
+
+ /**
+ * Current date. May temporarily hold unaccepted value when looking for a next valid date.
+ * Equal to null only before the first iteration.
+ *
+ * @var Carbon
+ */
+ protected $current;
+
+ /**
+ * Timezone of current date. Taken from the start date.
+ *
+ * @var \DateTimeZone|null
+ */
+ protected $timezone;
+
+ /**
+ * The cached validation result for current date.
+ *
+ * @var bool|string|null
+ */
+ protected $validationResult;
+
+ /**
+ * Create a new instance.
+ *
+ * @return static
+ */
+ public static function create()
+ {
+ return static::createFromArray(func_get_args());
+ }
+
+ /**
+ * Create a new instance from an array of parameters.
+ *
+ * @param array $params
+ *
+ * @return static
+ */
+ public static function createFromArray(array $params)
+ {
+ // PHP 5.3 equivalent of new static(...$params).
+ $reflection = new ReflectionClass(get_class());
+ /** @var static $instance */
+ $instance = $reflection->newInstanceArgs($params);
+
+ return $instance;
+ }
+
+ /**
+ * Create CarbonPeriod from ISO 8601 string.
+ *
+ * @param string $iso
+ * @param int|null $options
+ *
+ * @return static
+ */
+ public static function createFromIso($iso, $options = null)
+ {
+ $params = static::parseIso8601($iso);
+
+ $instance = static::createFromArray($params);
+
+ if ($options !== null) {
+ $instance->setOptions($options);
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Return whether given interval contains non zero value of any time unit.
+ *
+ * @param \DateInterval $interval
+ *
+ * @return bool
+ */
+ protected static function intervalHasTime(DateInterval $interval)
+ {
+ // The array_key_exists and get_object_vars are used as a workaround to check microsecond support.
+ // Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following bug:
+ // https://bugs.php.net/bug.php?id=74852
+ return $interval->h || $interval->i || $interval->s || array_key_exists('f', get_object_vars($interval)) && $interval->f;
+ }
+
+ /**
+ * Return whether given callable is a string pointing to one of Carbon's is* methods
+ * and should be automatically converted to a filter callback.
+ *
+ * @param callable $callable
+ *
+ * @return bool
+ */
+ protected static function isCarbonPredicateMethod($callable)
+ {
+ return is_string($callable) && substr($callable, 0, 2) === 'is' && (method_exists('Carbon\Carbon', $callable) || Carbon::hasMacro($callable));
+ }
+
+ /**
+ * Return whether given variable is an ISO 8601 specification.
+ *
+ * Note: Check is very basic, as actual validation will be done later when parsing.
+ * We just want to ensure that variable is not any other type of a valid parameter.
+ *
+ * @param mixed $var
+ *
+ * @return bool
+ */
+ protected static function isIso8601($var)
+ {
+ if (!is_string($var)) {
+ return false;
+ }
+
+ // Match slash but not within a timezone name.
+ $part = '[a-z]+(?:[_-][a-z]+)*';
+
+ preg_match("#\b$part/$part\b|(/)#i", $var, $match);
+
+ return isset($match[1]);
+ }
+
+ /**
+ * Parse given ISO 8601 string into an array of arguments.
+ *
+ * @param string $iso
+ *
+ * @return array
+ */
+ protected static function parseIso8601($iso)
+ {
+ $result = array();
+
+ $interval = null;
+ $start = null;
+ $end = null;
+
+ foreach (explode('/', $iso) as $key => $part) {
+ if ($key === 0 && preg_match('/^R([0-9]*)$/', $part, $match)) {
+ $parsed = strlen($match[1]) ? (int) $match[1] : null;
+ } elseif ($interval === null && $parsed = CarbonInterval::make($part)) {
+ $interval = $part;
+ } elseif ($start === null && $parsed = Carbon::make($part)) {
+ $start = $part;
+ } elseif ($end === null && $parsed = Carbon::make(static::addMissingParts($start, $part))) {
+ $end = $part;
+ } else {
+ throw new InvalidArgumentException("Invalid ISO 8601 specification: $iso.");
+ }
+
+ $result[] = $parsed;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Add missing parts of the target date from the soure date.
+ *
+ * @param string $source
+ * @param string $target
+ *
+ * @return string
+ */
+ protected static function addMissingParts($source, $target)
+ {
+ $pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/';
+
+ $result = preg_replace($pattern, $target, $source, 1, $count);
+
+ return $count ? $result : $target;
+ }
+
+ /**
+ * Register a custom macro.
+ *
+ * @param string $name
+ * @param object|callable $macro
+ *
+ * @return void
+ */
+ public static function macro($name, $macro)
+ {
+ static::$macros[$name] = $macro;
+ }
+
+ /**
+ * Remove all macros.
+ */
+ public static function resetMacros()
+ {
+ static::$macros = array();
+ }
+
+ /**
+ * Register macros from a mixin object.
+ *
+ * @param object $mixin
+ *
+ * @throws \ReflectionException
+ *
+ * @return void
+ */
+ public static function mixin($mixin)
+ {
+ $reflection = new ReflectionClass($mixin);
+
+ $methods = $reflection->getMethods(
+ ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
+ );
+
+ foreach ($methods as $method) {
+ $method->setAccessible(true);
+
+ static::macro($method->name, $method->invoke($mixin));
+ }
+ }
+
+ /**
+ * Check if macro is registered.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public static function hasMacro($name)
+ {
+ return isset(static::$macros[$name]);
+ }
+
+ /**
+ * Provide static proxy for instance aliases.
+ *
+ * @param string $method
+ * @param array $parameters
+ *
+ * @return mixed
+ */
+ public static function __callStatic($method, $parameters)
+ {
+ return call_user_func_array(
+ array(new static, $method), $parameters
+ );
+ }
+
+ /**
+ * CarbonPeriod constructor.
+ *
+ * @throws InvalidArgumentException
+ */
+ public function __construct()
+ {
+ // Parse and assign arguments one by one. First argument may be an ISO 8601 spec,
+ // which will be first parsed into parts and then processed the same way.
+ $arguments = func_get_args();
+
+ if (count($arguments) && static::isIso8601($iso = $arguments[0])) {
+ array_splice($arguments, 0, 1, static::parseIso8601($iso));
+ }
+
+ foreach ($arguments as $argument) {
+ if ($this->dateInterval === null && $parsed = CarbonInterval::make($argument)) {
+ $this->setDateInterval($parsed);
+ } elseif ($this->startDate === null && $parsed = Carbon::make($argument)) {
+ $this->setStartDate($parsed);
+ } elseif ($this->endDate === null && $parsed = Carbon::make($argument)) {
+ $this->setEndDate($parsed);
+ } elseif ($this->recurrences === null && $this->endDate === null && is_numeric($argument)) {
+ $this->setRecurrences($argument);
+ } elseif ($this->options === null && (is_int($argument) || $argument === null)) {
+ $this->setOptions($argument);
+ } else {
+ throw new InvalidArgumentException('Invalid constructor parameters.');
+ }
+ }
+
+ if ($this->startDate === null) {
+ $this->setStartDate(Carbon::now());
+ }
+
+ if ($this->dateInterval === null) {
+ $this->setDateInterval(CarbonInterval::day());
+
+ $this->isDefaultInterval = true;
+ }
+
+ if ($this->options === null) {
+ $this->setOptions(0);
+ }
+ }
+
+ /**
+ * Change the period date interval.
+ *
+ * @param DateInterval|string $interval
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function setDateInterval($interval)
+ {
+ if (!$interval = CarbonInterval::make($interval)) {
+ throw new InvalidArgumentException('Invalid interval.');
+ }
+
+ if ($interval->spec() === 'PT0S') {
+ throw new InvalidArgumentException('Empty interval is not accepted.');
+ }
+
+ $this->dateInterval = $interval;
+
+ $this->isDefaultInterval = false;
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Invert the period date interval.
+ *
+ * @return $this
+ */
+ public function invertDateInterval()
+ {
+ $interval = $this->dateInterval->invert();
+
+ return $this->setDateInterval($interval);
+ }
+
+ /**
+ * Set start and end date.
+ *
+ * @param DateTime|DateTimeInterface|string $start
+ * @param DateTime|DateTimeInterface|string|null $end
+ *
+ * @return $this
+ */
+ public function setDates($start, $end)
+ {
+ $this->setStartDate($start);
+ $this->setEndDate($end);
+
+ return $this;
+ }
+
+ /**
+ * Change the period options.
+ *
+ * @param int|null $options
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function setOptions($options)
+ {
+ if (!is_int($options) && !is_null($options)) {
+ throw new InvalidArgumentException('Invalid options.');
+ }
+
+ $this->options = $options ?: 0;
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Get the period options.
+ *
+ * @return int
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Toggle given options on or off.
+ *
+ * @param int $options
+ * @param bool|null $state
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function toggleOptions($options, $state = null)
+ {
+ if ($state === null) {
+ $state = ($this->options & $options) !== $options;
+ }
+
+ return $this->setOptions($state ?
+ $this->options | $options :
+ $this->options & ~$options
+ );
+ }
+
+ /**
+ * Toggle EXCLUDE_START_DATE option.
+ *
+ * @param bool $state
+ *
+ * @return $this
+ */
+ public function excludeStartDate($state = true)
+ {
+ return $this->toggleOptions(static::EXCLUDE_START_DATE, $state);
+ }
+
+ /**
+ * Toggle EXCLUDE_END_DATE option.
+ *
+ * @param bool $state
+ *
+ * @return $this
+ */
+ public function excludeEndDate($state = true)
+ {
+ return $this->toggleOptions(static::EXCLUDE_END_DATE, $state);
+ }
+
+ /**
+ * Get the underlying date interval.
+ *
+ * @return CarbonInterval
+ */
+ public function getDateInterval()
+ {
+ return $this->dateInterval->copy();
+ }
+
+ /**
+ * Get start date of the period.
+ *
+ * @return Carbon
+ */
+ public function getStartDate()
+ {
+ return $this->startDate->copy();
+ }
+
+ /**
+ * Get end date of the period.
+ *
+ * @return Carbon|null
+ */
+ public function getEndDate()
+ {
+ if ($this->endDate) {
+ return $this->endDate->copy();
+ }
+ }
+
+ /**
+ * Get number of recurrences.
+ *
+ * @return int|null
+ */
+ public function getRecurrences()
+ {
+ return $this->recurrences;
+ }
+
+ /**
+ * Returns true if the start date should be excluded.
+ *
+ * @return bool
+ */
+ public function isStartExcluded()
+ {
+ return ($this->options & static::EXCLUDE_START_DATE) !== 0;
+ }
+
+ /**
+ * Returns true if the end date should be excluded.
+ *
+ * @return bool
+ */
+ public function isEndExcluded()
+ {
+ return ($this->options & static::EXCLUDE_END_DATE) !== 0;
+ }
+
+ /**
+ * Add a filter to the stack.
+ *
+ * @param callable $callback
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function addFilter($callback, $name = null)
+ {
+ $tuple = $this->createFilterTuple(func_get_args());
+
+ $this->filters[] = $tuple;
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Prepend a filter to the stack.
+ *
+ * @param callable $callback
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function prependFilter($callback, $name = null)
+ {
+ $tuple = $this->createFilterTuple(func_get_args());
+
+ array_unshift($this->filters, $tuple);
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Create a filter tuple from raw parameters.
+ *
+ * Will create an automatic filter callback for one of Carbon's is* methods.
+ *
+ * @param array $parameters
+ *
+ * @return array
+ */
+ protected function createFilterTuple(array $parameters)
+ {
+ $method = array_shift($parameters);
+
+ if (!$this->isCarbonPredicateMethod($method)) {
+ return array($method, array_shift($parameters));
+ }
+
+ return array(function ($date) use ($method, $parameters) {
+ return call_user_func_array(array($date, $method), $parameters);
+ }, $method);
+ }
+
+ /**
+ * Remove a filter by instance or name.
+ *
+ * @param callable|string $filter
+ *
+ * @return $this
+ */
+ public function removeFilter($filter)
+ {
+ $key = is_callable($filter) ? 0 : 1;
+
+ $this->filters = array_values(array_filter(
+ $this->filters,
+ function ($tuple) use ($key, $filter) {
+ return $tuple[$key] !== $filter;
+ }
+ ));
+
+ $this->updateInternalState();
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Return whether given instance or name is in the filter stack.
+ *
+ * @param callable|string $filter
+ *
+ * @return bool
+ */
+ public function hasFilter($filter)
+ {
+ $key = is_callable($filter) ? 0 : 1;
+
+ foreach ($this->filters as $tuple) {
+ if ($tuple[$key] === $filter) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Get filters stack.
+ *
+ * @return array
+ */
+ public function getFilters()
+ {
+ return $this->filters;
+ }
+
+ /**
+ * Set filters stack.
+ *
+ * @param array $filters
+ *
+ * @return $this
+ */
+ public function setFilters(array $filters)
+ {
+ $this->filters = $filters;
+
+ $this->updateInternalState();
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Reset filters stack.
+ *
+ * @return $this
+ */
+ public function resetFilters()
+ {
+ $this->filters = array();
+
+ if ($this->endDate !== null) {
+ $this->filters[] = array(static::END_DATE_FILTER, null);
+ }
+
+ if ($this->recurrences !== null) {
+ $this->filters[] = array(static::RECURRENCES_FILTER, null);
+ }
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Update properties after removing built-in filters.
+ *
+ * @return void
+ */
+ protected function updateInternalState()
+ {
+ if (!$this->hasFilter(static::END_DATE_FILTER)) {
+ $this->endDate = null;
+ }
+
+ if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
+ $this->recurrences = null;
+ }
+ }
+
+ /**
+ * Add a recurrences filter (set maximum number of recurrences).
+ *
+ * @param int|null $recurrences
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function setRecurrences($recurrences)
+ {
+ if (!is_numeric($recurrences) && !is_null($recurrences) || $recurrences < 0) {
+ throw new InvalidArgumentException('Invalid number of recurrences.');
+ }
+
+ if ($recurrences === null) {
+ return $this->removeFilter(static::RECURRENCES_FILTER);
+ }
+
+ $this->recurrences = (int) $recurrences;
+
+ if (!$this->hasFilter(static::RECURRENCES_FILTER)) {
+ return $this->addFilter(static::RECURRENCES_FILTER);
+ }
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * Recurrences filter callback (limits number of recurrences).
+ *
+ * @param \Carbon\Carbon $current
+ * @param int $key
+ *
+ * @return bool|string
+ */
+ protected function filterRecurrences($current, $key)
+ {
+ if ($key < $this->recurrences) {
+ return true;
+ }
+
+ return static::END_ITERATION;
+ }
+
+ /**
+ * Change the period start date.
+ *
+ * @param DateTime|DateTimeInterface|string $date
+ * @param bool|null $inclusive
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function setStartDate($date, $inclusive = null)
+ {
+ if (!$date = Carbon::make($date)) {
+ throw new InvalidArgumentException('Invalid start date.');
+ }
+
+ $this->startDate = $date;
+
+ if ($inclusive !== null) {
+ $this->toggleOptions(static::EXCLUDE_START_DATE, !$inclusive);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Change the period end date.
+ *
+ * @param DateTime|DateTimeInterface|string|null $date
+ * @param bool|null $inclusive
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return $this
+ */
+ public function setEndDate($date, $inclusive = null)
+ {
+ if (!is_null($date) && !$date = Carbon::make($date)) {
+ throw new InvalidArgumentException('Invalid end date.');
+ }
+
+ if (!$date) {
+ return $this->removeFilter(static::END_DATE_FILTER);
+ }
+
+ $this->endDate = $date;
+
+ if ($inclusive !== null) {
+ $this->toggleOptions(static::EXCLUDE_END_DATE, !$inclusive);
+ }
+
+ if (!$this->hasFilter(static::END_DATE_FILTER)) {
+ return $this->addFilter(static::END_DATE_FILTER);
+ }
+
+ $this->handleChangedParameters();
+
+ return $this;
+ }
+
+ /**
+ * End date filter callback.
+ *
+ * @param \Carbon\Carbon $current
+ *
+ * @return bool|string
+ */
+ protected function filterEndDate($current)
+ {
+ if (!$this->isEndExcluded() && $current == $this->endDate) {
+ return true;
+ }
+
+ if ($this->dateInterval->invert ? $current > $this->endDate : $current < $this->endDate) {
+ return true;
+ }
+
+ return static::END_ITERATION;
+ }
+
+ /**
+ * End iteration filter callback.
+ *
+ * @return string
+ */
+ protected function endIteration()
+ {
+ return static::END_ITERATION;
+ }
+
+ /**
+ * Handle change of the parameters.
+ */
+ protected function handleChangedParameters()
+ {
+ $this->validationResult = null;
+ }
+
+ /**
+ * Validate current date and stop iteration when necessary.
+ *
+ * Returns true when current date is valid, false if it is not, or static::END_ITERATION
+ * when iteration should be stopped.
+ *
+ * @return bool|string
+ */
+ protected function validateCurrentDate()
+ {
+ if ($this->current === null) {
+ $this->rewind();
+ }
+
+ // Check after the first rewind to avoid repeating the initial validation.
+ if ($this->validationResult !== null) {
+ return $this->validationResult;
+ }
+
+ return $this->validationResult = $this->checkFilters();
+ }
+
+ /**
+ * Check whether current value and key pass all the filters.
+ *
+ * @return bool|string
+ */
+ protected function checkFilters()
+ {
+ $current = $this->prepareForReturn($this->current);
+
+ foreach ($this->filters as $tuple) {
+ $result = call_user_func(
+ $tuple[0], $current->copy(), $this->key, $this
+ );
+
+ if ($result === static::END_ITERATION) {
+ return static::END_ITERATION;
+ }
+
+ if (!$result) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Prepare given date to be returned to the external logic.
+ *
+ * @param Carbon $date
+ *
+ * @return Carbon
+ */
+ protected function prepareForReturn(Carbon $date)
+ {
+ $date = $date->copy();
+
+ if ($this->timezone) {
+ $date->setTimezone($this->timezone);
+ }
+
+ return $date;
+ }
+
+ /**
+ * Check if the current position is valid.
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->validateCurrentDate() === true;
+ }
+
+ /**
+ * Return the current key.
+ *
+ * @return int|null
+ */
+ public function key()
+ {
+ if ($this->valid()) {
+ return $this->key;
+ }
+ }
+
+ /**
+ * Return the current date.
+ *
+ * @return Carbon|null
+ */
+ public function current()
+ {
+ if ($this->valid()) {
+ return $this->prepareForReturn($this->current);
+ }
+ }
+
+ /**
+ * Move forward to the next date.
+ *
+ * @throws \RuntimeException
+ *
+ * @return void
+ */
+ public function next()
+ {
+ if ($this->current === null) {
+ $this->rewind();
+ }
+
+ if ($this->validationResult !== static::END_ITERATION) {
+ $this->key++;
+
+ $this->incrementCurrentDateUntilValid();
+ }
+ }
+
+ /**
+ * Rewind to the start date.
+ *
+ * Iterating over a date in the UTC timezone avoids bug during backward DST change.
+ *
+ * @see https://bugs.php.net/bug.php?id=72255
+ * @see https://bugs.php.net/bug.php?id=74274
+ * @see https://wiki.php.net/rfc/datetime_and_daylight_saving_time
+ *
+ * @throws \RuntimeException
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->key = 0;
+ $this->current = $this->startDate->copy();
+ $this->timezone = static::intervalHasTime($this->dateInterval) ? $this->current->getTimezone() : null;
+
+ if ($this->timezone) {
+ $this->current->setTimezone('UTC');
+ }
+
+ $this->validationResult = null;
+
+ if ($this->isStartExcluded() || $this->validateCurrentDate() === false) {
+ $this->incrementCurrentDateUntilValid();
+ }
+ }
+
+ /**
+ * Skip iterations and returns iteration state (false if ended, true if still valid).
+ *
+ * @param int $count steps number to skip (1 by default)
+ *
+ * @return bool
+ */
+ public function skip($count = 1)
+ {
+ for ($i = $count; $this->valid() && $i > 0; $i--) {
+ $this->next();
+ }
+
+ return $this->valid();
+ }
+
+ /**
+ * Keep incrementing the current date until a valid date is found or the iteration is ended.
+ *
+ * @throws \RuntimeException
+ *
+ * @return void
+ */
+ protected function incrementCurrentDateUntilValid()
+ {
+ $attempts = 0;
+
+ do {
+ $this->current->add($this->dateInterval);
+
+ $this->validationResult = null;
+
+ if (++$attempts > static::NEXT_MAX_ATTEMPTS) {
+ throw new RuntimeException('Could not find next valid date.');
+ }
+ } while ($this->validateCurrentDate() === false);
+ }
+
+ /**
+ * Format the date period as ISO 8601.
+ *
+ * @return string
+ */
+ public function toIso8601String()
+ {
+ $parts = array();
+
+ if ($this->recurrences !== null) {
+ $parts[] = 'R'.$this->recurrences;
+ }
+
+ $parts[] = $this->startDate->toIso8601String();
+
+ $parts[] = $this->dateInterval->spec();
+
+ if ($this->endDate !== null) {
+ $parts[] = $this->endDate->toIso8601String();
+ }
+
+ return implode('/', $parts);
+ }
+
+ /**
+ * Convert the date period into a string.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ $translator = Carbon::getTranslator();
+
+ $parts = array();
+
+ $format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay()
+ ? 'Y-m-d H:i:s'
+ : 'Y-m-d';
+
+ if ($this->recurrences !== null) {
+ $parts[] = $translator->transChoice('period_recurrences', $this->recurrences, array(':count' => $this->recurrences));
+ }
+
+ $parts[] = $translator->trans('period_interval', array(':interval' => $this->dateInterval->forHumans()));
+
+ $parts[] = $translator->trans('period_start_date', array(':date' => $this->startDate->format($format)));
+
+ if ($this->endDate !== null) {
+ $parts[] = $translator->trans('period_end_date', array(':date' => $this->endDate->format($format)));
+ }
+
+ $result = implode(' ', $parts);
+
+ return mb_strtoupper(mb_substr($result, 0, 1)).mb_substr($result, 1);
+ }
+
+ /**
+ * Format the date period as ISO 8601.
+ *
+ * @return string
+ */
+ public function spec()
+ {
+ return $this->toIso8601String();
+ }
+
+ /**
+ * Convert the date period into an array without changing current iteration state.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $state = array(
+ $this->key,
+ $this->current ? $this->current->copy() : null,
+ $this->validationResult,
+ );
+
+ $result = iterator_to_array($this);
+
+ list(
+ $this->key,
+ $this->current,
+ $this->validationResult
+ ) = $state;
+
+ return $result;
+ }
+
+ /**
+ * Count dates in the date period.
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->toArray());
+ }
+
+ /**
+ * Return the first date in the date period.
+ *
+ * @return Carbon|null
+ */
+ public function first()
+ {
+ if ($array = $this->toArray()) {
+ return $array[0];
+ }
+ }
+
+ /**
+ * Return the last date in the date period.
+ *
+ * @return Carbon|null
+ */
+ public function last()
+ {
+ if ($array = $this->toArray()) {
+ return $array[count($array) - 1];
+ }
+ }
+
+ /**
+ * Call given macro.
+ *
+ * @param string $name
+ * @param array $parameters
+ *
+ * @return mixed
+ */
+ protected function callMacro($name, $parameters)
+ {
+ $macro = static::$macros[$name];
+
+ $reflection = new ReflectionFunction($macro);
+
+ $reflectionParameters = $reflection->getParameters();
+
+ $expectedCount = count($reflectionParameters);
+ $actualCount = count($parameters);
+
+ if ($expectedCount > $actualCount && $reflectionParameters[$expectedCount - 1]->name === 'self') {
+ for ($i = $actualCount; $i < $expectedCount - 1; $i++) {
+ $parameters[] = $reflectionParameters[$i]->getDefaultValue();
+ }
+
+ $parameters[] = $this;
+ }
+
+ if ($macro instanceof Closure && method_exists($macro, 'bindTo')) {
+ $macro = $macro->bindTo($this, get_class($this));
+ }
+
+ return call_user_func_array($macro, $parameters);
+ }
+
+ /**
+ * Convert the date period into a string.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Add aliases for setters.
+ *
+ * CarbonPeriod::days(3)->hours(5)->invert()
+ * ->sinceNow()->until('2010-01-10')
+ * ->filter(...)
+ * ->count()
+ *
+ * Note: We use magic method to let static and instance aliases with the same names.
+ *
+ * @param string $method
+ * @param array $parameters
+ *
+ * @return mixed
+ */
+ public function __call($method, $parameters)
+ {
+ if (static::hasMacro($method)) {
+ return $this->callMacro($method, $parameters);
+ }
+
+ $first = count($parameters) >= 1 ? $parameters[0] : null;
+ $second = count($parameters) >= 2 ? $parameters[1] : null;
+
+ switch ($method) {
+ case 'start':
+ case 'since':
+ return $this->setStartDate($first, $second);
+
+ case 'sinceNow':
+ return $this->setStartDate(new Carbon, $first);
+
+ case 'end':
+ case 'until':
+ return $this->setEndDate($first, $second);
+
+ case 'untilNow':
+ return $this->setEndDate(new Carbon, $first);
+
+ case 'dates':
+ case 'between':
+ return $this->setDates($first, $second);
+
+ case 'recurrences':
+ case 'times':
+ return $this->setRecurrences($first);
+
+ case 'options':
+ return $this->setOptions($first);
+
+ case 'toggle':
+ return $this->toggleOptions($first, $second);
+
+ case 'filter':
+ case 'push':
+ return $this->addFilter($first, $second);
+
+ case 'prepend':
+ return $this->prependFilter($first, $second);
+
+ case 'filters':
+ return $this->setFilters($first ?: array());
+
+ case 'interval':
+ case 'each':
+ case 'every':
+ case 'step':
+ case 'stepBy':
+ return $this->setDateInterval($first);
+
+ case 'invert':
+ return $this->invertDateInterval();
+
+ case 'years':
+ case 'year':
+ case 'months':
+ case 'month':
+ case 'weeks':
+ case 'week':
+ case 'days':
+ case 'dayz':
+ case 'day':
+ case 'hours':
+ case 'hour':
+ case 'minutes':
+ case 'minute':
+ case 'seconds':
+ case 'second':
+ return $this->setDateInterval(call_user_func(
+ // Override default P1D when instantiating via fluent setters.
+ array($this->isDefaultInterval ? new CarbonInterval('PT0S') : $this->dateInterval, $method),
+ count($parameters) === 0 ? 1 : $first
+ ));
+ }
+
+ throw new BadMethodCallException("Method $method does not exist.");
+ }
+}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php b/application/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php
new file mode 100644
index 0000000..1b0d473
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Carbon\Exceptions;
+
+use Exception;
+use InvalidArgumentException;
+
+class InvalidDateException extends InvalidArgumentException
+{
+ /**
+ * The invalid field.
+ *
+ * @var string
+ */
+ private $field;
+
+ /**
+ * The invalid value.
+ *
+ * @var mixed
+ */
+ private $value;
+
+ /**
+ * Constructor.
+ *
+ * @param string $field
+ * @param mixed $value
+ * @param int $code
+ * @param \Exception|null $previous
+ */
+ public function __construct($field, $value, $code = 0, Exception $previous = null)
+ {
+ $this->field = $field;
+ $this->value = $value;
+ parent::__construct($field.' : '.$value.' is not a valid value.', $code, $previous);
+ }
+
+ /**
+ * Get the invalid field.
+ *
+ * @return string
+ */
+ public function getField()
+ {
+ return $this->field;
+ }
+
+ /**
+ * Get the invalid value.
+ *
+ * @return mixed
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/af.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/af.php
index 86ab541..5cf6a8d 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/af.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/af.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 jaar|:count jare',
- 'month' => '1 maand|:count maande',
- 'week' => '1 week|:count weke',
- 'day' => '1 dag|:count dae',
- 'hour' => '1 uur|:count ure',
- 'minute' => '1 minuut|:count minute',
- 'second' => '1 sekond|:count sekondes',
- 'ago' => ':time terug',
- 'from_now' => ':time van nou af',
- 'after' => ':time na',
- 'before' => ':time voor',
+ 'year' => ':count jaar|:count jare',
+ 'y' => ':count jaar|:count jare',
+ 'month' => ':count maand|:count maande',
+ 'm' => ':count maand|:count maande',
+ 'week' => ':count week|:count weke',
+ 'w' => ':count week|:count weke',
+ 'day' => ':count dag|:count dae',
+ 'd' => ':count dag|:count dae',
+ 'hour' => ':count uur|:count ure',
+ 'h' => ':count uur|:count ure',
+ 'minute' => ':count minuut|:count minute',
+ 'min' => ':count minuut|:count minute',
+ 'second' => ':count sekond|:count sekondes',
+ 's' => ':count sekond|:count sekondes',
+ 'ago' => ':time terug',
+ 'from_now' => ':time van nou af',
+ 'after' => ':time na',
+ 'before' => ':time voor',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ar.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ar.php
index 76b2772..de8f6b8 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ar.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ar.php
@@ -8,24 +8,24 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
-/**
- * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/ar/date.php
- */
return array(
- 'year' => '{0}سنة|{1}سنة|{2}سنتين|[3,10]:count سنوات|[11,Inf]:count سنة',
- 'month' => '{0}شهر|{1} شهر|{2}شهرين|[3,10]:count أشهر|[11,Inf]:count شهر',
- 'week' => '{0}إسبوع|{1}إسبوع|{2}إسبوعين|[3,10]:count أسابيع|[11,Inf]:count إسبوع',
- 'day' => '{0}يوم|{1}يوم|{2}يومين|[3,10]:count أيام|[11,Inf] يوم',
- 'hour' => '{0}ساعة|{1}ساعة|{2}ساعتين|[3,10]:count ساعات|[11,Inf]:count ساعة',
- 'minute' => '{0}دقيقة|{1}دقيقة|{2}دقيقتين|[3,10]:count دقائق|[11,Inf]:count دقيقة',
- 'second' => '{0}ثانية|{1}ثانية|{2}ثانيتين|[3,10]:count ثوان|[11,Inf]:count ثانية',
- 'ago' => 'منذ :time',
- 'from_now' => 'من الآن :time',
- 'after' => 'بعد :time',
- 'before' => 'قبل :time',
+ 'year' => '{0}سنة|{1}سنة|{2}سنتين|[3,10]:count سنوات|[11,Inf]:count سنة',
+ 'y' => '{0}سنة|{1}سنة|{2}سنتين|[3,10]:count سنوات|[11,Inf]:count سنة',
+ 'month' => '{0}شهر|{1} شهر|{2}شهرين|[3,10]:count أشهر|[11,Inf]:count شهر',
+ 'm' => '{0}شهر|{1} شهر|{2}شهرين|[3,10]:count أشهر|[11,Inf]:count شهر',
+ 'week' => '{0}أسبوع|{1}أسبوع|{2}أسبوعين|[3,10]:count أسابيع|[11,Inf]:count أسبوع',
+ 'w' => '{0}أسبوع|{1}أسبوع|{2}أسبوعين|[3,10]:count أسابيع|[11,Inf]:count أسبوع',
+ 'day' => '{0}يوم|{1}يوم|{2}يومين|[3,10]:count أيام|[11,Inf] يوم',
+ 'd' => '{0}يوم|{1}يوم|{2}يومين|[3,10]:count أيام|[11,Inf] يوم',
+ 'hour' => '{0}ساعة|{1}ساعة|{2}ساعتين|[3,10]:count ساعات|[11,Inf]:count ساعة',
+ 'h' => '{0}ساعة|{1}ساعة|{2}ساعتين|[3,10]:count ساعات|[11,Inf]:count ساعة',
+ 'minute' => '{0}دقيقة|{1}دقيقة|{2}دقيقتين|[3,10]:count دقائق|[11,Inf]:count دقيقة',
+ 'min' => '{0}دقيقة|{1}دقيقة|{2}دقيقتين|[3,10]:count دقائق|[11,Inf]:count دقيقة',
+ 'second' => '{0}ثانية|{1}ثانية|{2}ثانيتين|[3,10]:count ثوان|[11,Inf]:count ثانية',
+ 's' => '{0}ثانية|{1}ثانية|{2}ثانيتين|[3,10]:count ثوان|[11,Inf]:count ثانية',
+ 'ago' => 'منذ :time',
+ 'from_now' => ':time من الآن',
+ 'after' => 'بعد :time',
+ 'before' => 'قبل :time',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ar_Shakl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ar_Shakl.php
new file mode 100644
index 0000000..846ae02
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ar_Shakl.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '[0,1] سَنَة|{2} سَنَتَيْن|[3,10]:count سَنَوَات|[11,Inf]:count سَنَة',
+ 'y' => '[0,1] سَنَة|{2} سَنَتَيْن|[3,10]:count سَنَوَات|[11,Inf]:count سَنَة',
+ 'month' => '[0,1] شَهْرَ|{2} شَهْرَيْن|[3,10]:count أَشْهُر|[11,Inf]:count شَهْرَ',
+ 'm' => '[0,1] شَهْرَ|{2} شَهْرَيْن|[3,10]:count أَشْهُر|[11,Inf]:count شَهْرَ',
+ 'week' => '[0,1] أُسْبُوع|{2} أُسْبُوعَيْن|[3,10]:count أَسَابِيع|[11,Inf]:count أُسْبُوع',
+ 'w' => '[0,1] أُسْبُوع|{2} أُسْبُوعَيْن|[3,10]:count أَسَابِيع|[11,Inf]:count أُسْبُوع',
+ 'day' => '[0,1] يَوْم|{2} يَوْمَيْن|[3,10]:count أَيَّام|[11,Inf] يَوْم',
+ 'd' => '[0,1] يَوْم|{2} يَوْمَيْن|[3,10]:count أَيَّام|[11,Inf] يَوْم',
+ 'hour' => '[0,1] سَاعَة|{2} سَاعَتَيْن|[3,10]:count سَاعَات|[11,Inf]:count سَاعَة',
+ 'h' => '[0,1] سَاعَة|{2} سَاعَتَيْن|[3,10]:count سَاعَات|[11,Inf]:count سَاعَة',
+ 'minute' => '[0,1] دَقِيقَة|{2} دَقِيقَتَيْن|[3,10]:count دَقَائِق|[11,Inf]:count دَقِيقَة',
+ 'min' => '[0,1] دَقِيقَة|{2} دَقِيقَتَيْن|[3,10]:count دَقَائِق|[11,Inf]:count دَقِيقَة',
+ 'second' => '[0,1] ثَانِيَة|{2} ثَانِيَتَيْن|[3,10]:count ثَوَان|[11,Inf]:count ثَانِيَة',
+ 's' => '[0,1] ثَانِيَة|{2} ثَانِيَتَيْن|[3,10]:count ثَوَان|[11,Inf]:count ثَانِيَة',
+ 'ago' => 'مُنْذُ :time',
+ 'from_now' => 'مِنَ الْآن :time',
+ 'after' => 'بَعْدَ :time',
+ 'before' => 'قَبْلَ :time',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/az.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/az.php
index 455d262..25f5c4a 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/az.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/az.php
@@ -1,4 +1,5 @@
':count il',
- 'month' => ':count ay',
- 'week' => ':count həftə',
- 'day' => ':count gün',
- 'hour' => ':count saat',
- 'minute' => ':count dəqiqə',
- 'second' => ':count saniyə',
- 'ago' => ':time öncə',
- 'from_now' => ':time sonra',
- 'after' => ':time sonra',
- 'before' => ':time öncə'
+ 'year' => ':count il',
+ 'y' => ':count il',
+ 'month' => ':count ay',
+ 'm' => ':count ay',
+ 'week' => ':count həftə',
+ 'w' => ':count həftə',
+ 'day' => ':count gün',
+ 'd' => ':count gün',
+ 'hour' => ':count saat',
+ 'h' => ':count saat',
+ 'minute' => ':count dəqiqə',
+ 'min' => ':count dəqiqə',
+ 'second' => ':count saniyə',
+ 's' => ':count saniyə',
+ 'ago' => ':time əvvəl',
+ 'from_now' => ':time sonra',
+ 'after' => ':time sonra',
+ 'before' => ':time əvvəl',
+ 'diff_now' => 'indi',
+ 'diff_yesterday' => 'dünən',
+ 'diff_tomorrow' => 'sabah',
+ 'diff_before_yesterday' => 'srağagün',
+ 'diff_after_tomorrow' => 'birisi gün',
+ 'period_recurrences' => ':count dəfədən bir',
+ 'period_interval' => 'hər :interval',
+ 'period_start_date' => ':date tarixindən başlayaraq',
+ 'period_end_date' => ':date tarixinədək',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/bg.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/bg.php
index d70d780..d9e510b 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/bg.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/bg.php
@@ -8,24 +8,24 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
-/**
- * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/bg/date.php
- */
return array(
- 'year' => '1 година|:count години',
- 'month' => '1 месец|:count месеца',
- 'week' => '1 седмица|:count седмици',
- 'day' => '1 ден|:count дни',
- 'hour' => '1 час|:count часа',
- 'minute' => '1 минута|:count минути',
- 'second' => '1 секунда|:count секунди',
- 'ago' => 'преди :time',
- 'from_now' => ':time от сега',
- 'after' => 'след :time',
- 'before' => 'преди :time',
+ 'year' => ':count година|:count години',
+ 'y' => ':count година|:count години',
+ 'month' => ':count месец|:count месеца',
+ 'm' => ':count месец|:count месеца',
+ 'week' => ':count седмица|:count седмици',
+ 'w' => ':count седмица|:count седмици',
+ 'day' => ':count ден|:count дни',
+ 'd' => ':count ден|:count дни',
+ 'hour' => ':count час|:count часа',
+ 'h' => ':count час|:count часа',
+ 'minute' => ':count минута|:count минути',
+ 'min' => ':count минута|:count минути',
+ 'second' => ':count секунда|:count секунди',
+ 's' => ':count секунда|:count секунди',
+ 'ago' => 'преди :time',
+ 'from_now' => ':time от сега',
+ 'after' => 'след :time',
+ 'before' => 'преди :time',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/bn.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/bn.php
index 41357cd..5817599 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/bn.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/bn.php
@@ -1,4 +1,5 @@
'১ বছর|:count বছর',
- 'month' => '১ মাস|:count মাস',
- 'week' => '১ সপ্তাহ|:count সপ্তাহ',
- 'day' => '১ দিন|:count দিন',
- 'hour' => '১ ঘন্টা|:count ঘন্টা',
- 'minute' => '১ মিনিট|:count মিনিট',
- 'second' => '১ সেকেন্ড|:count সেকেন্ড',
- 'ago' => ':time পূর্বে',
- 'from_now' => 'এখন থেকে :time',
- 'after' => ':time পরে',
- 'before' => ':time আগে',
+ 'year' => '১ বছর|:count বছর',
+ 'y' => '১ বছর|:count বছর',
+ 'month' => '১ মাস|:count মাস',
+ 'm' => '১ মাস|:count মাস',
+ 'week' => '১ সপ্তাহ|:count সপ্তাহ',
+ 'w' => '১ সপ্তাহ|:count সপ্তাহ',
+ 'day' => '১ দিন|:count দিন',
+ 'd' => '১ দিন|:count দিন',
+ 'hour' => '১ ঘন্টা|:count ঘন্টা',
+ 'h' => '১ ঘন্টা|:count ঘন্টা',
+ 'minute' => '১ মিনিট|:count মিনিট',
+ 'min' => '১ মিনিট|:count মিনিট',
+ 'second' => '১ সেকেন্ড|:count সেকেন্ড',
+ 's' => '১ সেকেন্ড|:count সেকেন্ড',
+ 'ago' => ':time পূর্বে',
+ 'from_now' => 'এখন থেকে :time',
+ 'after' => ':time পরে',
+ 'before' => ':time আগে',
+ 'diff_now' => 'এখন',
+ 'diff_yesterday' => 'গতকাল',
+ 'diff_tomorrow' => 'আগামীকাল',
+ 'period_recurrences' => ':count বার|:count বার',
+ 'period_interval' => 'প্রতি :interval',
+ 'period_start_date' => ':date থেকে',
+ 'period_end_date' => ':date পর্যন্ত',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/bs_BA.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/bs_BA.php
new file mode 100644
index 0000000..7a9b05a
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/bs_BA.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count godina|:count godine|:count godina',
+ 'y' => ':count godina|:count godine|:count godina',
+ 'month' => ':count mjesec|:count mjeseca|:count mjeseci',
+ 'm' => ':count mjesec|:count mjeseca|:count mjeseci',
+ 'week' => ':count nedjelja|:count nedjelje|:count nedjelja',
+ 'w' => ':count nedjelja|:count nedjelje|:count nedjelja',
+ 'day' => ':count dan|:count dana|:count dana',
+ 'd' => ':count dan|:count dana|:count dana',
+ 'hour' => ':count sat|:count sata|:count sati',
+ 'h' => ':count sat|:count sata|:count sati',
+ 'minute' => ':count minut|:count minuta|:count minuta',
+ 'min' => ':count minut|:count minuta|:count minuta',
+ 'second' => ':count sekund|:count sekunda|:count sekundi',
+ 's' => ':count sekund|:count sekunda|:count sekundi',
+ 'ago' => 'prije :time',
+ 'from_now' => 'za :time',
+ 'after' => 'nakon :time',
+ 'before' => ':time ranije',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ca.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ca.php
index 8145161..c854b5a 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ca.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ca.php
@@ -1,4 +1,5 @@
'1 any|:count anys',
- 'month' => '1 mes|:count mesos',
- 'week' => '1 setmana|:count setmanes',
- 'day' => '1 dia|:count díes',
- 'hour' => '1 hora|:count hores',
- 'minute' => '1 minut|:count minuts',
- 'second' => '1 segon|:count segons',
- 'ago' => 'Fa :time',
- 'from_now' => 'Dins de :time',
- 'after' => ':time després',
- 'before' => ':time abans',
+ 'year' => ':count any|:count anys',
+ 'y' => ':count any|:count anys',
+ 'month' => ':count mes|:count mesos',
+ 'm' => ':count mes|:count mesos',
+ 'week' => ':count setmana|:count setmanes',
+ 'w' => ':count setmana|:count setmanes',
+ 'day' => ':count dia|:count dies',
+ 'd' => ':count dia|:count dies',
+ 'hour' => ':count hora|:count hores',
+ 'h' => ':count hora|:count hores',
+ 'minute' => ':count minut|:count minuts',
+ 'min' => ':count minut|:count minuts',
+ 'second' => ':count segon|:count segons',
+ 's' => ':count segon|:count segons',
+ 'ago' => 'fa :time',
+ 'from_now' => 'd\'aquí :time',
+ 'after' => ':time després',
+ 'before' => ':time abans',
+ 'diff_now' => 'ara mateix',
+ 'diff_yesterday' => 'ahir',
+ 'diff_tomorrow' => 'demà',
+ 'diff_before_yesterday' => "abans d'ahir",
+ 'diff_after_tomorrow' => 'demà passat',
+ 'period_recurrences' => ':count cop|:count cops',
+ 'period_interval' => 'cada :interval',
+ 'period_start_date' => 'de :date',
+ 'period_end_date' => 'fins a :date',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/cs.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/cs.php
index 26a78b3..a447ce2 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/cs.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/cs.php
@@ -1,4 +1,5 @@
'1 rok|:count roky|:count let',
- 'month' => '1 měsíc|:count měsíce|:count měsíců',
- 'week' => '1 týden|:count týdny|:count týdnů',
- 'day' => '1 den|:count dny|:count dní',
- 'hour' => '1 hodinu|:count hodiny|:count hodin',
- 'minute' => '1 minutu|:count minuty|:count minut',
- 'second' => '1 sekundu|:count sekundy|:count sekund',
- 'ago' => 'před :time',
- 'from_now' => 'za :time',
- 'after' => ':time později',
- 'before' => ':time předtím',
+ 'year' => ':count rok|:count roky|:count let',
+ 'y' => ':count rok|:count roky|:count let',
+ 'month' => ':count měsíc|:count měsíce|:count měsíců',
+ 'm' => ':count měsíc|:count měsíce|:count měsíců',
+ 'week' => ':count týden|:count týdny|:count týdnů',
+ 'w' => ':count týden|:count týdny|:count týdnů',
+ 'day' => ':count den|:count dny|:count dní',
+ 'd' => ':count den|:count dny|:count dní',
+ 'hour' => ':count hodinu|:count hodiny|:count hodin',
+ 'h' => ':count hodinu|:count hodiny|:count hodin',
+ 'minute' => ':count minutu|:count minuty|:count minut',
+ 'min' => ':count minutu|:count minuty|:count minut',
+ 'second' => ':count sekundu|:count sekundy|:count sekund',
+ 's' => ':count sekundu|:count sekundy|:count sekund',
+ 'ago' => ':time nazpět',
+ 'from_now' => 'za :time',
+ 'after' => ':time později',
+ 'before' => ':time předtím',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/cy.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/cy.php
new file mode 100644
index 0000000..c93750e
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/cy.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+return array(
+ 'year' => '1 flwyddyn|:count blynedd',
+ 'y' => ':countbl',
+ 'month' => '1 mis|:count fis',
+ 'm' => ':countmi',
+ 'week' => ':count wythnos',
+ 'w' => ':countw',
+ 'day' => ':count diwrnod',
+ 'd' => ':countd',
+ 'hour' => ':count awr',
+ 'h' => ':counth',
+ 'minute' => ':count munud',
+ 'min' => ':countm',
+ 'second' => ':count eiliad',
+ 's' => ':counts',
+ 'ago' => ':time yn ôl',
+ 'from_now' => ':time o hyn ymlaen',
+ 'after' => ':time ar ôl',
+ 'before' => ':time o\'r blaen',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/da.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/da.php
index d5c6a0a..86507b0 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/da.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/da.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 år|:count år',
- 'month' => '1 måned|:count måneder',
- 'week' => '1 uge|:count uger',
- 'day' => '1 dag|:count dage',
- 'hour' => '1 time|:count timer',
- 'minute' => '1 minut|:count minutter',
- 'second' => '1 sekund|:count sekunder',
- 'ago' => ':time siden',
- 'from_now' => 'om :time',
- 'after' => ':time efter',
- 'before' => ':time før',
+ 'year' => ':count år|:count år',
+ 'y' => ':count år|:count år',
+ 'month' => ':count måned|:count måneder',
+ 'm' => ':count måned|:count måneder',
+ 'week' => ':count uge|:count uger',
+ 'w' => ':count uge|:count uger',
+ 'day' => ':count dag|:count dage',
+ 'd' => ':count dag|:count dage',
+ 'hour' => ':count time|:count timer',
+ 'h' => ':count time|:count timer',
+ 'minute' => ':count minut|:count minutter',
+ 'min' => ':count minut|:count minutter',
+ 'second' => ':count sekund|:count sekunder',
+ 's' => ':count sekund|:count sekunder',
+ 'ago' => ':time siden',
+ 'from_now' => 'om :time',
+ 'after' => ':time efter',
+ 'before' => ':time før',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/de.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/de.php
index bf0af71..5ea2a03 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/de.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/de.php
@@ -3,36 +3,44 @@
/*
* This file is part of the Carbon package.
*
- * (c) Michael Hohl
+ * (c) Brian Nesbitt
*
- * This file is released under the terms of CC0.
- * CC0 is even more permissive than the MIT license, allowing you to use the code in
- * any manner you want, without any copyright headers, notices, or other attribution.
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 Jahr|:count Jahre',
- 'month' => '1 Monat|:count Monate',
- 'week' => '1 Woche|:count Wochen',
- 'day' => '1 Tag|:count Tage',
- 'hour' => '1 Stunde|:count Stunden',
- 'minute' => '1 Minute|:count Minuten',
- 'second' => '1 Sekunde|:count Sekunden',
- 'ago' => 'vor :time',
- 'from_now' => 'in :time',
- 'after' => ':time später',
- 'before' => ':time zuvor',
+ 'year' => ':count Jahr|:count Jahre',
+ 'y' => ':countJ|:countJ',
+ 'month' => ':count Monat|:count Monate',
+ 'm' => ':countMon|:countMon',
+ 'week' => ':count Woche|:count Wochen',
+ 'w' => ':countWo|:countWo',
+ 'day' => ':count Tag|:count Tage',
+ 'd' => ':countTg|:countTg',
+ 'hour' => ':count Stunde|:count Stunden',
+ 'h' => ':countStd|:countStd',
+ 'minute' => ':count Minute|:count Minuten',
+ 'min' => ':countMin|:countMin',
+ 'second' => ':count Sekunde|:count Sekunden',
+ 's' => ':countSek|:countSek',
+ 'ago' => 'vor :time',
+ 'from_now' => 'in :time',
+ 'after' => ':time später',
+ 'before' => ':time zuvor',
+
+ 'year_from_now' => ':count Jahr|:count Jahren',
+ 'month_from_now' => ':count Monat|:count Monaten',
+ 'week_from_now' => ':count Woche|:count Wochen',
+ 'day_from_now' => ':count Tag|:count Tagen',
+ 'year_ago' => ':count Jahr|:count Jahren',
+ 'month_ago' => ':count Monat|:count Monaten',
+ 'week_ago' => ':count Woche|:count Wochen',
+ 'day_ago' => ':count Tag|:count Tagen',
- 'year_from_now' => '1 Jahr|:count Jahren',
- 'month_from_now' => '1 Monat|:count Monaten',
- 'week_from_now' => '1 Woche|:count Wochen',
- 'day_from_now' => '1 Tag|:count Tagen',
- 'year_ago' => '1 Jahr|:count Jahren',
- 'month_ago' => '1 Monat|:count Monaten',
- 'week_ago' => '1 Woche|:count Wochen',
- 'day_ago' => '1 Tag|:count Tagen',
+ 'diff_now' => 'Gerade eben',
+ 'diff_yesterday' => 'Gestern',
+ 'diff_tomorrow' => 'Heute',
+ 'diff_before_yesterday' => 'Vorgestern',
+ 'diff_after_tomorrow' => 'Übermorgen',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/dv_MV.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/dv_MV.php
new file mode 100644
index 0000000..e3c50b3
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/dv_MV.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '{0}އަހަރެއް|[1,Inf]:count އަހަރު',
+ 'y' => '{0}އަހަރެއް|[1,Inf]:count އަހަރު',
+ 'month' => '{0}މައްސަރެއް|[1,Inf]:count މަސް',
+ 'm' => '{0}މައްސަރެއް|[1,Inf]:count މަސް',
+ 'week' => '{0}ހަފްތާއެއް|[1,Inf]:count ހަފްތާ',
+ 'w' => '{0}ހަފްތާއެއް|[1,Inf]:count ހަފްތާ',
+ 'day' => '{0}ދުވަސް|[1,Inf]:count ދުވަސް',
+ 'd' => '{0}ދުވަސް|[1,Inf]:count ދުވަސް',
+ 'hour' => '{0}ގަޑިއިރެއް|[1,Inf]:count ގަޑި',
+ 'h' => '{0}ގަޑިއިރެއް|[1,Inf]:count ގަޑި',
+ 'minute' => '{0}މިނެޓެއް|[1,Inf]:count މިނެޓް',
+ 'min' => '{0}މިނެޓެއް|[1,Inf]:count މިނެޓް',
+ 'second' => '{0}ސިކުންތެއް|[1,Inf]:count ސިކުންތު',
+ 's' => '{0}ސިކުންތެއް|[1,Inf]:count ސިކުންތު',
+ 'ago' => ':time ކުރިން',
+ 'from_now' => ':time ފަހުން',
+ 'after' => ':time ފަހުން',
+ 'before' => ':time ކުރި',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/el.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/el.php
index 1ecb271..16b3f44 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/el.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/el.php
@@ -1,4 +1,5 @@
'1 χρόνος|:count χρόνια',
- 'month' => '1 μήνας|:count μήνες',
- 'week' => '1 εβδομάδα|:count εβδομάδες',
- 'day' => '1 μέρα|:count μέρες',
- 'hour' => '1 ώρα|:count ώρες',
- 'minute' => '1 λεπτό|:count λεπτά',
- 'second' => '1 δευτερόλεπτο|:count δευτερόλεπτα',
- 'ago' => 'πρίν απο :time',
- 'from_now' => 'σε :time απο τώρα',
- 'after' => ':time μετά',
- 'before' => ':time πρίν'
+ 'year' => ':count χρόνος|:count χρόνια',
+ 'y' => ':count χρόνος|:count χρόνια',
+ 'month' => ':count μήνας|:count μήνες',
+ 'm' => ':count μήνας|:count μήνες',
+ 'week' => ':count εβδομάδα|:count εβδομάδες',
+ 'w' => ':count εβδομάδα|:count εβδομάδες',
+ 'day' => ':count μέρα|:count μέρες',
+ 'd' => ':count μέρα|:count μέρες',
+ 'hour' => ':count ώρα|:count ώρες',
+ 'h' => ':count ώρα|:count ώρες',
+ 'minute' => ':count λεπτό|:count λεπτά',
+ 'min' => ':count λεπτό|:count λεπτά',
+ 'second' => ':count δευτερόλεπτο|:count δευτερόλεπτα',
+ 's' => ':count δευτερόλεπτο|:count δευτερόλεπτα',
+ 'ago' => 'πριν από :time',
+ 'from_now' => 'σε :time από τώρα',
+ 'after' => ':time μετά',
+ 'before' => ':time πριν',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/en.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/en.php
index e0ad273..a15c131 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/en.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/en.php
@@ -9,20 +9,32 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 year|:count years',
- 'month' => '1 month|:count months',
- 'week' => '1 week|:count weeks',
- 'day' => '1 day|:count days',
- 'hour' => '1 hour|:count hours',
- 'minute' => '1 minute|:count minutes',
- 'second' => '1 second|:count seconds',
- 'ago' => ':time ago',
- 'from_now' => ':time from now',
- 'after' => ':time after',
- 'before' => ':time before',
+ 'year' => ':count year|:count years',
+ 'y' => ':countyr|:countyrs',
+ 'month' => ':count month|:count months',
+ 'm' => ':countmo|:countmos',
+ 'week' => ':count week|:count weeks',
+ 'w' => ':countw|:countw',
+ 'day' => ':count day|:count days',
+ 'd' => ':countd|:countd',
+ 'hour' => ':count hour|:count hours',
+ 'h' => ':counth|:counth',
+ 'minute' => ':count minute|:count minutes',
+ 'min' => ':countm|:countm',
+ 'second' => ':count second|:count seconds',
+ 's' => ':counts|:counts',
+ 'ago' => ':time ago',
+ 'from_now' => ':time from now',
+ 'after' => ':time after',
+ 'before' => ':time before',
+ 'diff_now' => 'just now',
+ 'diff_yesterday' => 'yesterday',
+ 'diff_tomorrow' => 'tomorrow',
+ 'diff_before_yesterday' => 'before yesterday',
+ 'diff_after_tomorrow' => 'after tomorrow',
+ 'period_recurrences' => 'once|:count times',
+ 'period_interval' => 'every :interval',
+ 'period_start_date' => 'from :date',
+ 'period_end_date' => 'to :date',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/eo.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/eo.php
index 3175a27..c5b90b3 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/eo.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/eo.php
@@ -1,4 +1,5 @@
'1 jaro|:count jaroj',
- 'month' => '1 monato|:count monatoj',
- 'week' => '1 semajno|:count semajnoj',
- 'day' => '1 tago|:count tagoj',
- 'hour' => '1 horo|:count horoj',
- 'minute' => '1 minuto|:count minutoj',
- 'second' => '1 sekundo|:count sekundoj',
- 'ago' => 'antaŭ :time',
- 'from_now' => 'je :time',
- 'after' => ':time poste',
- 'before' => ':time antaŭe'
+ 'year' => ':count jaro|:count jaroj',
+ 'y' => ':count jaro|:count jaroj',
+ 'month' => ':count monato|:count monatoj',
+ 'm' => ':count monato|:count monatoj',
+ 'week' => ':count semajno|:count semajnoj',
+ 'w' => ':count semajno|:count semajnoj',
+ 'day' => ':count tago|:count tagoj',
+ 'd' => ':count tago|:count tagoj',
+ 'hour' => ':count horo|:count horoj',
+ 'h' => ':count horo|:count horoj',
+ 'minute' => ':count minuto|:count minutoj',
+ 'min' => ':count minuto|:count minutoj',
+ 'second' => ':count sekundo|:count sekundoj',
+ 's' => ':count sekundo|:count sekundoj',
+ 'ago' => 'antaŭ :time',
+ 'from_now' => 'je :time',
+ 'after' => ':time poste',
+ 'before' => ':time antaŭe',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/es.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/es.php
index 2da39a0..567a280 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/es.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/es.php
@@ -9,20 +9,28 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 año|:count años',
- 'month' => '1 mes|:count meses',
- 'week' => '1 semana|:count semanas',
- 'day' => '1 día|:count días',
- 'hour' => '1 hora|:count horas',
- 'minute' => '1 minuto|:count minutos',
- 'second' => '1 segundo|:count segundos',
- 'ago' => 'hace :time',
- 'from_now' => 'dentro de :time',
- 'after' => ':time después',
- 'before' => ':time antes',
+ 'year' => ':count año|:count años',
+ 'y' => ':count año|:count años',
+ 'month' => ':count mes|:count meses',
+ 'm' => ':count mes|:count meses',
+ 'week' => ':count semana|:count semanas',
+ 'w' => ':count semana|:count semanas',
+ 'day' => ':count día|:count días',
+ 'd' => ':count día|:count días',
+ 'hour' => ':count hora|:count horas',
+ 'h' => ':count hora|:count horas',
+ 'minute' => ':count minuto|:count minutos',
+ 'min' => ':count minuto|:count minutos',
+ 'second' => ':count segundo|:count segundos',
+ 's' => ':count segundo|:count segundos',
+ 'ago' => 'hace :time',
+ 'from_now' => 'dentro de :time',
+ 'after' => ':time después',
+ 'before' => ':time antes',
+ 'diff_now' => 'ahora mismo',
+ 'diff_yesterday' => 'ayer',
+ 'diff_tomorrow' => 'mañana',
+ 'diff_before_yesterday' => 'antier',
+ 'diff_after_tomorrow' => 'pasado mañana',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/et.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/et.php
index 68dfae6..2d9291e 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/et.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/et.php
@@ -1,4 +1,5 @@
'1 aasta|:count aastat',
- 'month' => '1 kuu|:count kuud',
- 'week' => '1 nädal|:count nädalat',
- 'day' => '1 päev|:count päeva',
- 'hour' => '1 tund|:count tundi',
- 'minute' => '1 minut|:count minutit',
- 'second' => '1 sekund|:count sekundit',
- 'ago' => ':time tagasi',
- 'from_now' => ':time pärast',
- 'after' => ':time pärast',
- 'before' => ':time enne',
+ 'year' => ':count aasta|:count aastat',
+ 'y' => ':count aasta|:count aastat',
+ 'month' => ':count kuu|:count kuud',
+ 'm' => ':count kuu|:count kuud',
+ 'week' => ':count nädal|:count nädalat',
+ 'w' => ':count nädal|:count nädalat',
+ 'day' => ':count päev|:count päeva',
+ 'd' => ':count päev|:count päeva',
+ 'hour' => ':count tund|:count tundi',
+ 'h' => ':count tund|:count tundi',
+ 'minute' => ':count minut|:count minutit',
+ 'min' => ':count minut|:count minutit',
+ 'second' => ':count sekund|:count sekundit',
+ 's' => ':count sekund|:count sekundit',
+ 'ago' => ':time tagasi',
+ 'from_now' => ':time pärast',
+ 'after' => ':time pärast',
+ 'before' => ':time enne',
'year_from_now' => ':count aasta',
'month_from_now' => ':count kuu',
'week_from_now' => ':count nädala',
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/eu.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/eu.php
index 79c4d12..1cb6b7c 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/eu.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/eu.php
@@ -1,4 +1,5 @@
'Urte 1|:count urte',
- 'month' => 'Hile 1|:count hile',
- 'week' => 'Aste 1|:count aste',
- 'day' => 'Egun 1|:count egun',
- 'hour' => 'Ordu 1|:count ordu',
- 'minute' => 'Minutu 1|:count minutu',
- 'second' => 'Segundu 1|:count segundu',
- 'ago' => 'Orain dela :time',
- 'from_now' => ':time barru',
- 'after' => ':time geroago',
- 'before' => ':time lehenago'
+ 'year' => 'Urte 1|:count urte',
+ 'y' => 'Urte 1|:count urte',
+ 'month' => 'Hile 1|:count hile',
+ 'm' => 'Hile 1|:count hile',
+ 'week' => 'Aste 1|:count aste',
+ 'w' => 'Aste 1|:count aste',
+ 'day' => 'Egun 1|:count egun',
+ 'd' => 'Egun 1|:count egun',
+ 'hour' => 'Ordu 1|:count ordu',
+ 'h' => 'Ordu 1|:count ordu',
+ 'minute' => 'Minutu 1|:count minutu',
+ 'min' => 'Minutu 1|:count minutu',
+ 'second' => 'Segundu 1|:count segundu',
+ 's' => 'Segundu 1|:count segundu',
+ 'ago' => 'Orain dela :time',
+ 'from_now' => ':time barru',
+ 'after' => ':time geroago',
+ 'before' => ':time lehenago',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/fa.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/fa.php
index 8b671da..31bec88 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/fa.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/fa.php
@@ -9,21 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
-
return array(
- 'year' => ':count سال',
- 'month' => ':count ماه',
- 'week' => ':count هفته',
- 'day' => ':count روز',
- 'hour' => ':count ساعت',
- 'minute' => ':count دقیقه',
- 'second' => ':count ثانیه',
- 'ago' => ':time پیش',
- 'from_now' => ':time بعد',
- 'after' => ':time پیش از',
- 'before' => ':time پس از',
+ 'year' => ':count سال',
+ 'y' => ':count سال',
+ 'month' => ':count ماه',
+ 'm' => ':count ماه',
+ 'week' => ':count هفته',
+ 'w' => ':count هفته',
+ 'day' => ':count روز',
+ 'd' => ':count روز',
+ 'hour' => ':count ساعت',
+ 'h' => ':count ساعت',
+ 'minute' => ':count دقیقه',
+ 'min' => ':count دقیقه',
+ 'second' => ':count ثانیه',
+ 's' => ':count ثانیه',
+ 'ago' => ':time پیش',
+ 'from_now' => ':time بعد',
+ 'after' => ':time پس از',
+ 'before' => ':time پیش از',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/fi.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/fi.php
index 6198f99..4818804 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/fi.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/fi.php
@@ -1,4 +1,5 @@
'1 vuosi|:count vuotta',
- 'month' => '1 kuukausi|:count kuukautta',
- 'week' => '1 viikko|:count viikkoa',
- 'day' => '1 päivä|:count päivää',
- 'hour' => '1 tunti|:count tuntia',
- 'minute' => '1 minuutti|:count minuuttia',
- 'second' => '1 sekunti|:count sekuntia',
- 'ago' => ':time sitten',
- 'from_now' => ':time tästä hetkestä',
- 'after' => ':time sen jälkeen',
- 'before' => ':time ennen'
+ 'year' => ':count vuosi|:count vuotta',
+ 'y' => ':count vuosi|:count vuotta',
+ 'month' => ':count kuukausi|:count kuukautta',
+ 'm' => ':count kuukausi|:count kuukautta',
+ 'week' => ':count viikko|:count viikkoa',
+ 'w' => ':count viikko|:count viikkoa',
+ 'day' => ':count päivä|:count päivää',
+ 'd' => ':count päivä|:count päivää',
+ 'hour' => ':count tunti|:count tuntia',
+ 'h' => ':count tunti|:count tuntia',
+ 'minute' => ':count minuutti|:count minuuttia',
+ 'min' => ':count minuutti|:count minuuttia',
+ 'second' => ':count sekunti|:count sekuntia',
+ 's' => ':count sekunti|:count sekuntia',
+ 'ago' => ':time sitten',
+ 'from_now' => ':time tästä hetkestä',
+ 'after' => ':time sen jälkeen',
+ 'before' => ':time ennen',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/fo.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/fo.php
index 740f03b..d91104b 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/fo.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/fo.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 ár|:count ár',
- 'month' => '1 mánaður|:count mánaðir',
- 'week' => '1 vika|:count vikur',
- 'day' => '1 dag|:count dagar',
- 'hour' => '1 tími|:count tímar',
- 'minute' => '1 minutt|:count minuttir',
- 'second' => '1 sekund|:count sekundir',
- 'ago' => ':time síðan',
- 'from_now' => 'um :time',
- 'after' => ':time aftaná',
- 'before' => ':time áðrenn',
+ 'year' => ':count ár|:count ár',
+ 'y' => ':count ár|:count ár',
+ 'month' => ':count mánaður|:count mánaðir',
+ 'm' => ':count mánaður|:count mánaðir',
+ 'week' => ':count vika|:count vikur',
+ 'w' => ':count vika|:count vikur',
+ 'day' => ':count dag|:count dagar',
+ 'd' => ':count dag|:count dagar',
+ 'hour' => ':count tími|:count tímar',
+ 'h' => ':count tími|:count tímar',
+ 'minute' => ':count minutt|:count minuttir',
+ 'min' => ':count minutt|:count minuttir',
+ 'second' => ':count sekund|:count sekundir',
+ 's' => ':count sekund|:count sekundir',
+ 'ago' => ':time síðan',
+ 'from_now' => 'um :time',
+ 'after' => ':time aftaná',
+ 'before' => ':time áðrenn',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/fr.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/fr.php
index 298131a..0b20cdd 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/fr.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/fr.php
@@ -9,20 +9,32 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 an|:count ans',
- 'month' => ':count mois',
- 'week' => '1 semaine|:count semaines',
- 'day' => '1 jour|:count jours',
- 'hour' => '1 heure|:count heures',
- 'minute' => '1 minute|:count minutes',
- 'second' => '1 seconde|:count secondes',
- 'ago' => 'il y a :time',
- 'from_now' => 'dans :time',
- 'after' => ':time après',
- 'before' => ':time avant',
+ 'year' => ':count an|:count ans',
+ 'y' => ':count an|:count ans',
+ 'month' => ':count mois',
+ 'm' => ':count mois',
+ 'week' => ':count semaine|:count semaines',
+ 'w' => ':count sem.',
+ 'day' => ':count jour|:count jours',
+ 'd' => ':count j.',
+ 'hour' => ':count heure|:count heures',
+ 'h' => ':count h.',
+ 'minute' => ':count minute|:count minutes',
+ 'min' => ':count min.',
+ 'second' => ':count seconde|:count secondes',
+ 's' => ':count sec.',
+ 'ago' => 'il y a :time',
+ 'from_now' => 'dans :time',
+ 'after' => ':time après',
+ 'before' => ':time avant',
+ 'diff_now' => "à l'instant",
+ 'diff_yesterday' => 'hier',
+ 'diff_tomorrow' => 'demain',
+ 'diff_before_yesterday' => 'avant-hier',
+ 'diff_after_tomorrow' => 'après-demain',
+ 'period_recurrences' => ':count fois',
+ 'period_interval' => 'tous les :interval',
+ 'period_start_date' => 'de :date',
+ 'period_end_date' => 'à :date',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/gl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/gl.php
new file mode 100644
index 0000000..cd22a31
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/gl.php
@@ -0,0 +1,24 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count ano|:count anos',
+ 'month' => ':count mes|:count meses',
+ 'week' => ':count semana|:count semanas',
+ 'day' => ':count día|:count días',
+ 'hour' => ':count hora|:count horas',
+ 'minute' => ':count minuto|:count minutos',
+ 'second' => ':count segundo|:count segundos',
+ 'ago' => 'fai :time',
+ 'from_now' => 'dentro de :time',
+ 'after' => ':time despois',
+ 'before' => ':time antes',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/gu.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/gu.php
new file mode 100644
index 0000000..7759dfc
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/gu.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count વર્ષ|:count વર્ષો',
+ 'y' => ':countવર્ષ|:countવર્ષો',
+ 'month' => ':count મહિનો|:count મહિના',
+ 'm' => ':countમહિનો|:countમહિના',
+ 'week' => ':count અઠવાડિયું|:count અઠવાડિયા',
+ 'w' => ':countઅઠ.|:countઅઠ.',
+ 'day' => ':count દિવસ|:count દિવસો',
+ 'd' => ':countદિ.|:countદિ.',
+ 'hour' => ':count કલાક|:count કલાકો',
+ 'h' => ':countક.|:countક.',
+ 'minute' => ':count મિનિટ|:count મિનિટ',
+ 'min' => ':countમિ.|:countમિ.',
+ 'second' => ':count સેકેન્ડ|:count સેકેન્ડ',
+ 's' => ':countસે.|:countસે.',
+ 'ago' => ':time પહેલા',
+ 'from_now' => ':time અત્યારથી',
+ 'after' => ':time પછી',
+ 'before' => ':time પહેલા',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/he.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/he.php
index 681915b..2d4f4f8 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/he.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/he.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => 'שנה|{2}שנתיים|:count שנים',
- 'month' => 'חודש|{2}חודשיים|:count חודשים',
- 'week' => 'שבוע|{2}שבועיים|:count שבועות',
- 'day' => 'יום|{2}יומיים|:count ימים',
- 'hour' => 'שעה|{2}שעתיים|:count שעות',
- 'minute' => 'דקה|{2}דקותיים|:count דקות',
- 'second' => 'שניה|:count שניות',
- 'ago' => 'לפני :time',
- 'from_now' => 'בעוד :time',
- 'after' => 'אחרי :time',
- 'before' => 'לפני :time',
+ 'year' => 'שנה|{2}שנתיים|:count שנים',
+ 'y' => 'שנה|{2}שנתיים|:count שנים',
+ 'month' => 'חודש|{2}חודשיים|:count חודשים',
+ 'm' => 'חודש|{2}חודשיים|:count חודשים',
+ 'week' => 'שבוע|{2}שבועיים|:count שבועות',
+ 'w' => 'שבוע|{2}שבועיים|:count שבועות',
+ 'day' => 'יום|{2}יומיים|:count ימים',
+ 'd' => 'יום|{2}יומיים|:count ימים',
+ 'hour' => 'שעה|{2}שעתיים|:count שעות',
+ 'h' => 'שעה|{2}שעתיים|:count שעות',
+ 'minute' => 'דקה|{2}דקותיים|:count דקות',
+ 'min' => 'דקה|{2}דקותיים|:count דקות',
+ 'second' => 'שניה|:count שניות',
+ 's' => 'שניה|:count שניות',
+ 'ago' => 'לפני :time',
+ 'from_now' => 'בעוד :time',
+ 'after' => 'אחרי :time',
+ 'before' => 'לפני :time',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/hi.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/hi.php
new file mode 100644
index 0000000..6c670ee
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/hi.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '1 वर्ष|:count वर्षों',
+ 'y' => '1 वर्ष|:count वर्षों',
+ 'month' => '1 माह|:count महीने',
+ 'm' => '1 माह|:count महीने',
+ 'week' => '1 सप्ताह|:count सप्ताह',
+ 'w' => '1 सप्ताह|:count सप्ताह',
+ 'day' => '1 दिन|:count दिनों',
+ 'd' => '1 दिन|:count दिनों',
+ 'hour' => '1 घंटा|:count घंटे',
+ 'h' => '1 घंटा|:count घंटे',
+ 'minute' => '1 मिनट|:count मिनटों',
+ 'min' => '1 मिनट|:count मिनटों',
+ 'second' => '1 सेकंड|:count सेकंड',
+ 's' => '1 सेकंड|:count सेकंड',
+ 'ago' => ':time पूर्व',
+ 'from_now' => ':time से',
+ 'after' => ':time के बाद',
+ 'before' => ':time के पहले',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/hr.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/hr.php
index ea21ced..1a339de 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/hr.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/hr.php
@@ -1,4 +1,5 @@
':count godinu|:count godine|:count godina',
- 'month' => ':count mjesec|:count mjeseca|:count mjeseci',
- 'week' => ':count tjedan|:count tjedna|:count tjedana',
- 'day' => ':count dan|:count dana|:count dana',
- 'hour' => ':count sat|:count sata|:count sati',
- 'minute' => ':count minutu|:count minute |:count minuta',
- 'second' => ':count sekundu|:count sekunde|:count sekundi',
- 'ago' => 'prije :time',
- 'from_now' => 'za :time',
- 'after' => 'za :time',
- 'before' => 'prije :time'
+ 'year' => ':count godinu|:count godine|:count godina',
+ 'y' => ':count godinu|:count godine|:count godina',
+ 'month' => ':count mjesec|:count mjeseca|:count mjeseci',
+ 'm' => ':count mjesec|:count mjeseca|:count mjeseci',
+ 'week' => ':count tjedan|:count tjedna|:count tjedana',
+ 'w' => ':count tjedan|:count tjedna|:count tjedana',
+ 'day' => ':count dan|:count dana|:count dana',
+ 'd' => ':count dan|:count dana|:count dana',
+ 'hour' => ':count sat|:count sata|:count sati',
+ 'h' => ':count sat|:count sata|:count sati',
+ 'minute' => ':count minutu|:count minute |:count minuta',
+ 'min' => ':count minutu|:count minute |:count minuta',
+ 'second' => ':count sekundu|:count sekunde|:count sekundi',
+ 's' => ':count sekundu|:count sekunde|:count sekundi',
+ 'ago' => 'prije :time',
+ 'from_now' => 'za :time',
+ 'after' => 'za :time',
+ 'before' => 'prije :time',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/hu.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/hu.php
index f30c0c8..45daf41 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/hu.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/hu.php
@@ -1,4 +1,5 @@
'1 évvel|:count évvel',
- 'month' => '1 hónappal|:count hónappal',
- 'week' => '1 héttel|:count héttel',
- 'day' => '1 nappal|:count nappal',
- 'hour' => '1 órával|:count órával',
- 'minute' => '1 perccel|:count perccel',
- 'second' => '1 másodperccel|:count másodperccel',
- 'ago' => ':time korábban',
- 'from_now' => ':time később',
- 'after' => ':time később',
- 'before' => ':time korábban'
+ 'year' => ':count év',
+ 'y' => ':count év',
+ 'month' => ':count hónap',
+ 'm' => ':count hónap',
+ 'week' => ':count hét',
+ 'w' => ':count hét',
+ 'day' => ':count nap',
+ 'd' => ':count nap',
+ 'hour' => ':count óra',
+ 'h' => ':count óra',
+ 'minute' => ':count perc',
+ 'min' => ':count perc',
+ 'second' => ':count másodperc',
+ 's' => ':count másodperc',
+ 'ago' => ':time',
+ 'from_now' => ':time múlva',
+ 'after' => ':time később',
+ 'before' => ':time korábban',
+ 'year_ago' => ':count éve',
+ 'month_ago' => ':count hónapja',
+ 'week_ago' => ':count hete',
+ 'day_ago' => ':count napja',
+ 'hour_ago' => ':count órája',
+ 'minute_ago' => ':count perce',
+ 'second_ago' => ':count másodperce',
+ 'year_after' => ':count évvel',
+ 'month_after' => ':count hónappal',
+ 'week_after' => ':count héttel',
+ 'day_after' => ':count nappal',
+ 'hour_after' => ':count órával',
+ 'minute_after' => ':count perccel',
+ 'second_after' => ':count másodperccel',
+ 'year_before' => ':count évvel',
+ 'month_before' => ':count hónappal',
+ 'week_before' => ':count héttel',
+ 'day_before' => ':count nappal',
+ 'hour_before' => ':count órával',
+ 'minute_before' => ':count perccel',
+ 'second_before' => ':count másodperccel',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/hy.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/hy.php
new file mode 100644
index 0000000..d2665f2
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/hy.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count տարի',
+ 'y' => ':countտ',
+ 'month' => ':count ամիս',
+ 'm' => ':countամ',
+ 'week' => ':count շաբաթ',
+ 'w' => ':countշ',
+ 'day' => ':count օր',
+ 'd' => ':countօր',
+ 'hour' => ':count ժամ',
+ 'h' => ':countժ',
+ 'minute' => ':count րոպե',
+ 'min' => ':countր',
+ 'second' => ':count վարկյան',
+ 's' => ':countվրկ',
+ 'ago' => ':time առաջ',
+ 'from_now' => ':time ներկա պահից',
+ 'after' => ':time հետո',
+ 'before' => ':time առաջ',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/id.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/id.php
index 56757a5..7f7114f 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/id.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/id.php
@@ -1,4 +1,5 @@
':count tahun',
- 'month' => ':count bulan',
- 'week' => ':count minggu',
- 'day' => ':count hari',
- 'hour' => ':count jam',
- 'minute' => ':count menit',
- 'second' => ':count detik',
- 'ago' => ':time yang lalu',
- 'from_now' => ':time dari sekarang',
- 'after' => ':time setelah',
- 'before' => ':time sebelum'
+ 'year' => ':count tahun',
+ 'y' => ':count tahun',
+ 'month' => ':count bulan',
+ 'm' => ':count bulan',
+ 'week' => ':count minggu',
+ 'w' => ':count minggu',
+ 'day' => ':count hari',
+ 'd' => ':count hari',
+ 'hour' => ':count jam',
+ 'h' => ':count jam',
+ 'minute' => ':count menit',
+ 'min' => ':count menit',
+ 'second' => ':count detik',
+ 's' => ':count detik',
+ 'ago' => ':time yang lalu',
+ 'from_now' => ':time dari sekarang',
+ 'after' => ':time setelah',
+ 'before' => ':time sebelum',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/is.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/is.php
new file mode 100644
index 0000000..94c76a7
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/is.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '1 ár|:count ár',
+ 'y' => '1 ár|:count ár',
+ 'month' => '1 mánuður|:count mánuðir',
+ 'm' => '1 mánuður|:count mánuðir',
+ 'week' => '1 vika|:count vikur',
+ 'w' => '1 vika|:count vikur',
+ 'day' => '1 dagur|:count dagar',
+ 'd' => '1 dagur|:count dagar',
+ 'hour' => '1 klukkutími|:count klukkutímar',
+ 'h' => '1 klukkutími|:count klukkutímar',
+ 'minute' => '1 mínúta|:count mínútur',
+ 'min' => '1 mínúta|:count mínútur',
+ 'second' => '1 sekúnda|:count sekúndur',
+ 's' => '1 sekúnda|:count sekúndur',
+ 'ago' => ':time síðan',
+ 'from_now' => ':time síðan',
+ 'after' => ':time eftir',
+ 'before' => ':time fyrir',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/it.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/it.php
index 680e0f5..70bc6d7 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/it.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/it.php
@@ -9,20 +9,28 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 anno|:count anni',
- 'month' => '1 mese|:count mesi',
- 'week' => '1 settimana|:count settimane',
- 'day' => '1 giorno|:count giorni',
- 'hour' => '1 ora|:count ore',
- 'minute' => '1 minuto|:count minuti',
- 'second' => '1 secondo|:count secondi',
- 'ago' => ':time fa',
- 'from_now' => ':time da adesso',
- 'after' => ':time dopo',
- 'before' => ':time prima',
+ 'year' => ':count anno|:count anni',
+ 'y' => ':count anno|:count anni',
+ 'month' => ':count mese|:count mesi',
+ 'm' => ':count mese|:count mesi',
+ 'week' => ':count settimana|:count settimane',
+ 'w' => ':count settimana|:count settimane',
+ 'day' => ':count giorno|:count giorni',
+ 'd' => ':count giorno|:count giorni',
+ 'hour' => ':count ora|:count ore',
+ 'h' => ':count ora|:count ore',
+ 'minute' => ':count minuto|:count minuti',
+ 'min' => ':count minuto|:count minuti',
+ 'second' => ':count secondo|:count secondi',
+ 's' => ':count secondo|:count secondi',
+ 'ago' => ':time fa',
+ 'from_now' => 'tra :time',
+ 'after' => ':time dopo',
+ 'before' => ':time prima',
+ 'diff_now' => 'proprio ora',
+ 'diff_yesterday' => 'ieri',
+ 'diff_tomorrow' => 'domani',
+ 'diff_before_yesterday' => "l'altro ieri",
+ 'diff_after_tomorrow' => 'dopodomani',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ja.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ja.php
index 66cbf90..7119547 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ja.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ja.php
@@ -1,4 +1,5 @@
':count 年',
- 'month' => ':count ヶ月',
- 'week' => ':count 週間',
- 'day' => ':count 日',
- 'hour' => ':count 時間',
- 'minute' => ':count 分',
- 'second' => ':count 秒',
- 'ago' => ':time 前',
- 'from_now' => '今から :time',
- 'after' => ':time 後',
- 'before' => ':time 前'
+ 'year' => ':count年',
+ 'y' => ':count年',
+ 'month' => ':countヶ月',
+ 'm' => ':countヶ月',
+ 'week' => ':count週間',
+ 'w' => ':count週間',
+ 'day' => ':count日',
+ 'd' => ':count日',
+ 'hour' => ':count時間',
+ 'h' => ':count時間',
+ 'minute' => ':count分',
+ 'min' => ':count分',
+ 'second' => ':count秒',
+ 's' => ':count秒',
+ 'ago' => ':time前',
+ 'from_now' => '今から:time',
+ 'after' => ':time後',
+ 'before' => ':time前',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ka.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ka.php
new file mode 100644
index 0000000..a8dde7e
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ka.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count წლის',
+ 'y' => ':count წლის',
+ 'month' => ':count თვის',
+ 'm' => ':count თვის',
+ 'week' => ':count კვირის',
+ 'w' => ':count კვირის',
+ 'day' => ':count დღის',
+ 'd' => ':count დღის',
+ 'hour' => ':count საათის',
+ 'h' => ':count საათის',
+ 'minute' => ':count წუთის',
+ 'min' => ':count წუთის',
+ 'second' => ':count წამის',
+ 's' => ':count წამის',
+ 'ago' => ':time უკან',
+ 'from_now' => ':time შემდეგ',
+ 'after' => ':time შემდეგ',
+ 'before' => ':time უკან',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/kk.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/kk.php
new file mode 100644
index 0000000..8d113af
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/kk.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+return array(
+ 'year' => ':count жыл',
+ 'y' => ':count жыл',
+ 'month' => ':count ай',
+ 'm' => ':count ай',
+ 'week' => ':count апта',
+ 'w' => ':count апта',
+ 'day' => ':count күн',
+ 'd' => ':count күн',
+ 'hour' => ':count сағат',
+ 'h' => ':count сағат',
+ 'minute' => ':count минут',
+ 'min' => ':count минут',
+ 'second' => ':count секунд',
+ 's' => ':count секунд',
+ 'ago' => ':time бұрын',
+ 'from_now' => ':time кейін',
+ 'after' => ':time кейін',
+ 'before' => ':time бұрын',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/km.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/km.php
new file mode 100644
index 0000000..a104e06
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/km.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count ឆ្នាំ',
+ 'y' => ':count ឆ្នាំ',
+ 'month' => ':count ខែ',
+ 'm' => ':count ខែ',
+ 'week' => ':count សប្ដាហ៍',
+ 'w' => ':count សប្ដាហ៍',
+ 'day' => ':count ថ្ងៃ',
+ 'd' => ':count ថ្ងៃ',
+ 'hour' => ':count ម៉ោង',
+ 'h' => ':count ម៉ោង',
+ 'minute' => ':count នាទី',
+ 'min' => ':count នាទី',
+ 'second' => ':count វិនាទី',
+ 's' => ':count វិនាទី',
+ 'ago' => ':timeមុន',
+ 'from_now' => ':timeពីឥឡូវ',
+ 'after' => 'នៅក្រោយ :time',
+ 'before' => 'នៅមុន :time',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ko.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ko.php
index fa863d9..0209164 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ko.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ko.php
@@ -1,4 +1,5 @@
':count 년',
- 'month' => ':count 개월',
- 'week' => ':count 주일',
- 'day' => ':count 일',
- 'hour' => ':count 시간',
- 'minute' => ':count 분',
- 'second' => ':count 초',
- 'ago' => ':time 전',
- 'from_now' => ':time 후',
- 'after' => ':time 뒤',
- 'before' => ':time 앞',
+ 'year' => ':count 년',
+ 'y' => ':count 년',
+ 'month' => ':count 개월',
+ 'm' => ':count 개월',
+ 'week' => ':count 주일',
+ 'w' => ':count 주일',
+ 'day' => ':count 일',
+ 'd' => ':count 일',
+ 'hour' => ':count 시간',
+ 'h' => ':count 시간',
+ 'minute' => ':count 분',
+ 'min' => ':count 분',
+ 'second' => ':count 초',
+ 's' => ':count 초',
+ 'ago' => ':time 전',
+ 'from_now' => ':time 후',
+ 'after' => ':time 이후',
+ 'before' => ':time 이전',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/lt.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/lt.php
index af8ddcb..3f2fd1e 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/lt.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/lt.php
@@ -9,21 +9,30 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
-
return array(
- 'year' => '1 metus|:count metus|:count metų',
- 'month' => '1 menesį|:count menesius|:count menesių',
- 'week' => '1 savaitę|:count savaites|:count savaičių',
- 'day' => '1 dieną|:count dienas|:count dienų',
- 'hour' => '1 valandą|:count valandas|:count valandų',
- 'minute' => '1 minutę|:count minutes|:count minučių',
- 'second' => '1 sekundę|:count sekundes|:count sekundžių',
- 'ago' => 'prieš :time',
- 'from_now' => 'už :time',
- 'after' => 'po :time',
- 'before' => ':time nuo dabar',
+ 'year' => ':count metus|:count metus|:count metų',
+ 'y' => ':count metus|:count metus|:count metų',
+ 'month' => ':count mėnesį|:count mėnesius|:count mėnesių',
+ 'm' => ':count mėnesį|:count mėnesius|:count mėnesių',
+ 'week' => ':count savaitę|:count savaites|:count savaičių',
+ 'w' => ':count savaitę|:count savaites|:count savaičių',
+ 'day' => ':count dieną|:count dienas|:count dienų',
+ 'd' => ':count dieną|:count dienas|:count dienų',
+ 'hour' => ':count valandą|:count valandas|:count valandų',
+ 'h' => ':count valandą|:count valandas|:count valandų',
+ 'minute' => ':count minutę|:count minutes|:count minučių',
+ 'min' => ':count minutę|:count minutes|:count minučių',
+ 'second' => ':count sekundę|:count sekundes|:count sekundžių',
+ 's' => ':count sekundę|:count sekundes|:count sekundžių',
+ 'second_from_now' => ':count sekundės|:count sekundžių|:count sekundžių',
+ 'minute_from_now' => ':count minutės|:count minučių|:count minučių',
+ 'hour_from_now' => ':count valandos|:count valandų|:count valandų',
+ 'day_from_now' => ':count dienos|:count dienų|:count dienų',
+ 'week_from_now' => ':count savaitės|:count savaičių|:count savaičių',
+ 'month_from_now' => ':count mėnesio|:count mėnesių|:count mėnesių',
+ 'year_from_now' => ':count metų',
+ 'ago' => 'prieš :time',
+ 'from_now' => 'už :time',
+ 'after' => 'po :time',
+ 'before' => ':time nuo dabar',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/lv.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/lv.php
index fb66c22..363193d 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/lv.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/lv.php
@@ -1,43 +1,47 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '0 gadiem|:count gada|:count gadiem',
- 'month' => '0 mēnešiem|:count mēneša|:count mēnešiem',
- 'week' => '0 nedēļām|:count nedēļas|:count nedēļām',
- 'day' => '0 dienām|:count dienas|:count dienām',
- 'hour' => '0 stundām|:count stundas|:count stundām',
- 'minute' => '0 minūtēm|:count minūtes|:count minūtēm',
- 'second' => '0 sekundēm|:count sekundes|:count sekundēm',
- 'ago' => 'pirms :time',
- 'from_now' => 'pēc :time',
- 'after' => ':time vēlāk',
- 'before' => ':time pirms',
+ 'year' => '0 gadiem|:count gada|:count gadiem',
+ 'y' => '0 gadiem|:count gada|:count gadiem',
+ 'month' => '0 mēnešiem|:count mēneša|:count mēnešiem',
+ 'm' => '0 mēnešiem|:count mēneša|:count mēnešiem',
+ 'week' => '0 nedēļām|:count nedēļas|:count nedēļām',
+ 'w' => '0 nedēļām|:count nedēļas|:count nedēļām',
+ 'day' => '0 dienām|:count dienas|:count dienām',
+ 'd' => '0 dienām|:count dienas|:count dienām',
+ 'hour' => '0 stundām|:count stundas|:count stundām',
+ 'h' => '0 stundām|:count stundas|:count stundām',
+ 'minute' => '0 minūtēm|:count minūtes|:count minūtēm',
+ 'min' => '0 minūtēm|:count minūtes|:count minūtēm',
+ 'second' => '0 sekundēm|:count sekundes|:count sekundēm',
+ 's' => '0 sekundēm|:count sekundes|:count sekundēm',
+ 'ago' => 'pirms :time',
+ 'from_now' => 'pēc :time',
+ 'after' => ':time vēlāk',
+ 'before' => ':time pirms',
- 'year_after' => '0 gadus|:count gadu|:count gadus',
- 'month_after' => '0 mēnešus|:count mēnesi|:count mēnešus',
- 'week_after' => '0 nedēļas|:count nedēļu|:count nedēļas',
- 'day_after' => '0 dienas|:count dienu|:count dienas',
- 'hour_after' => '0 stundas|:count stundu|:count stundas',
- 'minute_after' => '0 minūtes|:count minūti|:count minūtes',
- 'second_after' => '0 sekundes|:count sekundi|:count sekundes',
+ 'year_after' => '0 gadus|:count gadu|:count gadus',
+ 'month_after' => '0 mēnešus|:count mēnesi|:count mēnešus',
+ 'week_after' => '0 nedēļas|:count nedēļu|:count nedēļas',
+ 'day_after' => '0 dienas|:count dienu|:count dienas',
+ 'hour_after' => '0 stundas|:count stundu|:count stundas',
+ 'minute_after' => '0 minūtes|:count minūti|:count minūtes',
+ 'second_after' => '0 sekundes|:count sekundi|:count sekundes',
- 'year_before' => '0 gadus|:count gadu|:count gadus',
- 'month_before' => '0 mēnešus|:count mēnesi|:count mēnešus',
- 'week_before' => '0 nedēļas|:count nedēļu|:count nedēļas',
- 'day_before' => '0 dienas|:count dienu|:count dienas',
- 'hour_before' => '0 stundas|:count stundu|:count stundas',
+ 'year_before' => '0 gadus|:count gadu|:count gadus',
+ 'month_before' => '0 mēnešus|:count mēnesi|:count mēnešus',
+ 'week_before' => '0 nedēļas|:count nedēļu|:count nedēļas',
+ 'day_before' => '0 dienas|:count dienu|:count dienas',
+ 'hour_before' => '0 stundas|:count stundu|:count stundas',
'minute_before' => '0 minūtes|:count minūti|:count minūtes',
'second_before' => '0 sekundes|:count sekundi|:count sekundes',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/mk.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/mk.php
new file mode 100644
index 0000000..c5ec12d
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/mk.php
@@ -0,0 +1,24 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count година|:count години',
+ 'month' => ':count месец|:count месеци',
+ 'week' => ':count седмица|:count седмици',
+ 'day' => ':count ден|:count дена',
+ 'hour' => ':count час|:count часа',
+ 'minute' => ':count минута|:count минути',
+ 'second' => ':count секунда|:count секунди',
+ 'ago' => 'пред :time',
+ 'from_now' => ':time од сега',
+ 'after' => 'по :time',
+ 'before' => 'пред :time',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/mn.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/mn.php
new file mode 100644
index 0000000..b26dce5
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/mn.php
@@ -0,0 +1,62 @@
+
+ *
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @translator Batmandakh Erdenebileg
+ */
+
+return array(
+ 'year' => ':count жил',
+ 'y' => ':count жил',
+ 'month' => ':count сар',
+ 'm' => ':count сар',
+ 'week' => ':count долоо хоног',
+ 'w' => ':count долоо хоног',
+ 'day' => ':count өдөр',
+ 'd' => ':count өдөр',
+ 'hour' => ':count цаг',
+ 'h' => ':countц',
+ 'minute' => ':count минут',
+ 'min' => ':countм',
+ 'second' => ':count секунд',
+ 's' => ':countс',
+
+ 'ago' => ':timeн өмнө',
+ 'year_ago' => ':count жилий',
+ 'month_ago' => ':count сары',
+ 'day_ago' => ':count хоногий',
+ 'hour_ago' => ':count цагий',
+ 'minute_ago' => ':count минуты',
+ 'second_ago' => ':count секунды',
+
+ 'from_now' => 'одоогоос :time',
+ 'year_from_now' => ':count жилийн дараа',
+ 'month_from_now' => ':count сарын дараа',
+ 'day_from_now' => ':count хоногийн дараа',
+ 'hour_from_now' => ':count цагийн дараа',
+ 'minute_from_now' => ':count минутын дараа',
+ 'second_from_now' => ':count секундын дараа',
+
+ // Does it required to make translation for before, after as follows? hmm, I think we've made it with ago and from now keywords already. Anyway, I've included it just in case of undesired action...
+ 'after' => ':timeн дараа',
+ 'year_after' => ':count жилий',
+ 'month_after' => ':count сары',
+ 'day_after' => ':count хоногий',
+ 'hour_after' => ':count цагий',
+ 'minute_after' => ':count минуты',
+ 'second_after' => ':count секунды',
+ 'before' => ':timeн өмнө',
+ 'year_before' => ':count жилий',
+ 'month_before' => ':count сары',
+ 'day_before' => ':count хоногий',
+ 'hour_before' => ':count цагий',
+ 'minute_before' => ':count минуты',
+ 'second_before' => ':count секунды',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ms.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ms.php
index 90304f5..ef57422 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ms.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ms.php
@@ -1,4 +1,5 @@
':count tahun',
- 'month' => ':count bulan',
- 'week' => ':count minggu',
- 'day' => ':count hari',
- 'hour' => ':count jam',
- 'minute' => ':count minit',
- 'second' => ':count saat',
- 'ago' => ':time yang lalu',
- 'from_now' => ':time dari sekarang',
- 'after' => ':time selepas',
- 'before' => ':time sebelum',
+ 'year' => ':count tahun',
+ 'y' => ':count tahun',
+ 'month' => ':count bulan',
+ 'm' => ':count bulan',
+ 'week' => ':count minggu',
+ 'w' => ':count minggu',
+ 'day' => ':count hari',
+ 'd' => ':count hari',
+ 'hour' => ':count jam',
+ 'h' => ':count jam',
+ 'minute' => ':count minit',
+ 'min' => ':count minit',
+ 'second' => ':count saat',
+ 's' => ':count saat',
+ 'ago' => ':time yang lalu',
+ 'from_now' => ':time dari sekarang',
+ 'after' => ':time selepas',
+ 'before' => ':time sebelum',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/my.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/my.php
new file mode 100644
index 0000000..e8e491e
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/my.php
@@ -0,0 +1,37 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count နှစ်|:count နှစ်',
+ 'y' => ':count နှစ်|:count နှစ်',
+ 'month' => ':count လ|:count လ',
+ 'm' => ':count လ|:count လ',
+ 'week' => ':count ပတ်|:count ပတ်',
+ 'w' => ':count ပတ်|:count ပတ်',
+ 'day' => ':count ရက်|:count ရက်',
+ 'd' => ':count ရက်|:count ရက်',
+ 'hour' => ':count နာရီ|:count နာရီ',
+ 'h' => ':count နာရီ|:count နာရီ',
+ 'minute' => ':count မိနစ်|:count မိနစ်',
+ 'min' => ':count မိနစ်|:count မိနစ်',
+ 'second' => ':count စက္ကန့်|:count စက္ကန့်',
+ 's' => ':count စက္ကန့်|:count စက္ကန့်',
+ 'ago' => 'လွန်ခဲ့သော :time က',
+ 'from_now' => 'ယခုမှစ၍နောက် :time အကြာ',
+ 'after' => ':time ကြာပြီးနောက်',
+ 'before' => ':time မတိုင်ခင်',
+ 'diff_now' => 'အခုလေးတင်',
+ 'diff_yesterday' => 'မနေ့က',
+ 'diff_tomorrow' => 'မနက်ဖြန်',
+ 'diff_before_yesterday' => 'တမြန်နေ့က',
+ 'diff_after_tomorrow' => 'တဘက်ခါ',
+ 'period_recurrences' => ':count ကြိမ်',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ne.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ne.php
new file mode 100644
index 0000000..0b528df
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ne.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count वर्ष',
+ 'y' => ':count वर्ष',
+ 'month' => ':count महिना',
+ 'm' => ':count महिना',
+ 'week' => ':count हप्ता',
+ 'w' => ':count हप्ता',
+ 'day' => ':count दिन',
+ 'd' => ':count दिन',
+ 'hour' => ':count घण्टा',
+ 'h' => ':count घण्टा',
+ 'minute' => ':count मिनेट',
+ 'min' => ':count मिनेट',
+ 'second' => ':count सेकेण्ड',
+ 's' => ':count सेकेण्ड',
+ 'ago' => ':time पहिले',
+ 'from_now' => ':time देखि',
+ 'after' => ':time पछि',
+ 'before' => ':time अघि',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/nl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/nl.php
index 00cd194..ec5a88e 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/nl.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/nl.php
@@ -1,4 +1,5 @@
'1 jaar|:count jaren',
- 'month' => '1 maand|:count maanden',
- 'week' => '1 week|:count weken',
- 'day' => '1 dag|:count dagen',
- 'hour' => ':count uur',
- 'minute' => '1 minuut|:count minuten',
- 'second' => '1 seconde|:count seconden',
- 'ago' => ':time geleden',
- 'from_now' => 'over :time',
- 'after' => ':time later',
- 'before' => ':time eerder',
+ 'year' => ':count jaar',
+ 'y' => ':count jaar',
+ 'month' => ':count maand|:count maanden',
+ 'm' => ':count maand|:count maanden',
+ 'week' => ':count week|:count weken',
+ 'w' => ':count week|:count weken',
+ 'day' => ':count dag|:count dagen',
+ 'd' => ':count dag|:count dagen',
+ 'hour' => ':count uur',
+ 'h' => ':count uur',
+ 'minute' => ':count minuut|:count minuten',
+ 'min' => ':count minuut|:count minuten',
+ 'second' => ':count seconde|:count seconden',
+ 's' => ':count seconde|:count seconden',
+ 'ago' => ':time geleden',
+ 'from_now' => 'over :time',
+ 'after' => ':time later',
+ 'before' => ':time eerder',
+ 'diff_now' => 'nu',
+ 'diff_yesterday' => 'gisteren',
+ 'diff_tomorrow' => 'morgen',
+ 'diff_after_tomorrow' => 'overmorgen',
+ 'diff_before_yesterday' => 'eergisteren',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/no.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/no.php
index 32a08c8..a6ece06 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/no.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/no.php
@@ -1,4 +1,5 @@
'1 år|:count år',
- 'month' => '1 måned|:count måneder',
- 'week' => '1 uke|:count uker',
- 'day' => '1 dag|:count dager',
- 'hour' => '1 time|:count timer',
- 'minute' => '1 minutt|:count minutter',
- 'second' => '1 sekund|:count sekunder',
- 'ago' => ':time siden',
- 'from_now' => 'om :time',
- 'after' => ':time etter',
- 'before' => ':time før'
+ 'year' => ':count år|:count år',
+ 'y' => ':count år|:count år',
+ 'month' => ':count måned|:count måneder',
+ 'm' => ':count måned|:count måneder',
+ 'week' => ':count uke|:count uker',
+ 'w' => ':count uke|:count uker',
+ 'day' => ':count dag|:count dager',
+ 'd' => ':count dag|:count dager',
+ 'hour' => ':count time|:count timer',
+ 'h' => ':count time|:count timer',
+ 'minute' => ':count minutt|:count minutter',
+ 'min' => ':count minutt|:count minutter',
+ 'second' => ':count sekund|:count sekunder',
+ 's' => ':count sekund|:count sekunder',
+ 'ago' => ':time siden',
+ 'from_now' => 'om :time',
+ 'after' => ':time etter',
+ 'before' => ':time før',
+ 'diff_now' => 'akkurat nå',
+ 'diff_yesterday' => 'i går',
+ 'diff_tomorrow' => 'i morgen',
+ 'diff_before_yesterday' => 'i forgårs',
+ 'diff_after_tomorrow' => 'i overmorgen',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/oc.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/oc.php
new file mode 100644
index 0000000..e89e94c
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/oc.php
@@ -0,0 +1,44 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+\Symfony\Component\Translation\PluralizationRules::set(function ($number) {
+ return $number == 1 ? 0 : 1;
+}, 'oc');
+
+return array(
+ 'year' => ':count an|:count ans',
+ 'y' => ':count an|:count ans',
+ 'month' => ':count mes|:count meses',
+ 'm' => ':count mes|:count meses',
+ 'week' => ':count setmana|:count setmanas',
+ 'w' => ':count setmana|:count setmanas',
+ 'day' => ':count jorn|:count jorns',
+ 'd' => ':count jorn|:count jorns',
+ 'hour' => ':count ora|:count oras',
+ 'h' => ':count ora|:count oras',
+ 'minute' => ':count minuta|:count minutas',
+ 'min' => ':count minuta|:count minutas',
+ 'second' => ':count segonda|:count segondas',
+ 's' => ':count segonda|:count segondas',
+ 'ago' => 'fa :time',
+ 'from_now' => 'dins :time',
+ 'after' => ':time aprèp',
+ 'before' => ':time abans',
+ 'diff_now' => 'ara meteis',
+ 'diff_yesterday' => 'ièr',
+ 'diff_tomorrow' => 'deman',
+ 'diff_before_yesterday' => 'ièr delà',
+ 'diff_after_tomorrow' => 'deman passat',
+ 'period_recurrences' => ':count còp|:count còps',
+ 'period_interval' => 'cada :interval',
+ 'period_start_date' => 'de :date',
+ 'period_end_date' => 'fins a :date',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/pl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/pl.php
index 1381d90..2308af2 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/pl.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/pl.php
@@ -1,4 +1,5 @@
'1 rok|:count lata|:count lat',
- 'month' => '1 miesiąc|:count miesiące|:count miesięcy',
- 'week' => '1 tydzień|:count tygodnie|:count tygodni',
- 'day' => '1 dzień|:count dni|:count dni',
- 'hour' => '1 godzina|:count godziny|:count godzin',
- 'minute' => '1 minuta|:count minuty|:count minut',
- 'second' => '1 sekunda|:count sekundy|:count sekund',
- 'ago' => ':time temu',
- 'from_now' => ':time od teraz',
- 'after' => ':time przed',
- 'before' => ':time po'
+ 'year' => ':count rok|:count lata|:count lat',
+ 'y' => ':countr|:countl',
+ 'month' => ':count miesiąc|:count miesiące|:count miesięcy',
+ 'm' => ':countmies',
+ 'week' => ':count tydzień|:count tygodnie|:count tygodni',
+ 'w' => ':counttyg',
+ 'day' => ':count dzień|:count dni|:count dni',
+ 'd' => ':countd',
+ 'hour' => ':count godzina|:count godziny|:count godzin',
+ 'h' => ':countg',
+ 'minute' => ':count minuta|:count minuty|:count minut',
+ 'min' => ':countm',
+ 'second' => ':count sekunda|:count sekundy|:count sekund',
+ 's' => ':counts',
+ 'ago' => ':time temu',
+ 'from_now' => ':time od teraz',
+ 'after' => ':time po',
+ 'before' => ':time przed',
+ 'diff_now' => 'przed chwilą',
+ 'diff_yesterday' => 'wczoraj',
+ 'diff_tomorrow' => 'jutro',
+ 'diff_before_yesterday' => 'przedwczoraj',
+ 'diff_after_tomorrow' => 'pojutrze',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ps.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ps.php
new file mode 100644
index 0000000..15c3296
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ps.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count کال|:count کاله',
+ 'y' => ':countکال|:countکاله',
+ 'month' => ':count مياشت|:count مياشتي',
+ 'm' => ':countمياشت|:countمياشتي',
+ 'week' => ':count اونۍ|:count اونۍ',
+ 'w' => ':countاونۍ|:countاونۍ',
+ 'day' => ':count ورځ|:count ورځي',
+ 'd' => ':countورځ|:countورځي',
+ 'hour' => ':count ساعت|:count ساعته',
+ 'h' => ':countساعت|:countساعته',
+ 'minute' => ':count دقيقه|:count دقيقې',
+ 'min' => ':countدقيقه|:countدقيقې',
+ 'second' => ':count ثانيه|:count ثانيې',
+ 's' => ':countثانيه|:countثانيې',
+ 'ago' => ':time دمخه',
+ 'from_now' => ':time له اوس څخه',
+ 'after' => ':time وروسته',
+ 'before' => ':time دمخه',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/pt.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/pt.php
index 4ee091f..392b121 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/pt.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/pt.php
@@ -1,4 +1,5 @@
'1 ano|:count anos',
- 'month' => '1 mês|:count meses',
- 'week' => '1 semana|:count semanas',
- 'day' => '1 dia|:count dias',
- 'hour' => '1 hora|:count horas',
- 'minute' => '1 minuto|:count minutos',
- 'second' => '1 segundo|:count segundos',
- 'ago' => ':time atrás',
- 'from_now' => 'em :time',
- 'after' => ':time depois',
- 'before' => ':time antes'
+ 'year' => ':count ano|:count anos',
+ 'y' => ':count ano|:count anos',
+ 'month' => ':count mês|:count meses',
+ 'm' => ':count mês|:count meses',
+ 'week' => ':count semana|:count semanas',
+ 'w' => ':count semana|:count semanas',
+ 'day' => ':count dia|:count dias',
+ 'd' => ':count dia|:count dias',
+ 'hour' => ':count hora|:count horas',
+ 'h' => ':count hora|:count horas',
+ 'minute' => ':count minuto|:count minutos',
+ 'min' => ':count minuto|:count minutos',
+ 'second' => ':count segundo|:count segundos',
+ 's' => ':count segundo|:count segundos',
+ 'ago' => ':time atrás',
+ 'from_now' => 'em :time',
+ 'after' => ':time depois',
+ 'before' => ':time antes',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/pt_BR.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/pt_BR.php
index cd9a90e..1f84eac 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/pt_BR.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/pt_BR.php
@@ -1,4 +1,5 @@
'1 ano|:count anos',
- 'month' => '1 mês|:count meses',
- 'week' => '1 semana|:count semanas',
- 'day' => '1 dia|:count dias',
- 'hour' => '1 hora|:count horas',
- 'minute' => '1 minuto|:count minutos',
- 'second' => '1 segundo|:count segundos',
- 'ago' => 'há :time',
- 'from_now' => 'dentro de :time',
- 'after' => 'após :time',
- 'before' => ':time atrás',
+ 'year' => ':count ano|:count anos',
+ 'y' => ':counta|:counta',
+ 'month' => ':count mês|:count meses',
+ 'm' => ':countm|:countm',
+ 'week' => ':count semana|:count semanas',
+ 'w' => ':countsem|:countsem',
+ 'day' => ':count dia|:count dias',
+ 'd' => ':countd|:countd',
+ 'hour' => ':count hora|:count horas',
+ 'h' => ':counth|:counth',
+ 'minute' => ':count minuto|:count minutos',
+ 'min' => ':countmin|:countmin',
+ 'second' => ':count segundo|:count segundos',
+ 's' => ':counts|:counts',
+ 'ago' => 'há :time',
+ 'from_now' => 'em :time',
+ 'after' => 'após :time',
+ 'before' => ':time atrás',
+ 'diff_now' => 'agora',
+ 'diff_yesterday' => 'ontem',
+ 'diff_tomorrow' => 'amanhã',
+ 'diff_before_yesterday' => 'anteontem',
+ 'diff_after_tomorrow' => 'depois de amanhã',
+ 'period_recurrences' => 'uma|:count vez',
+ 'period_interval' => 'toda :interval',
+ 'period_start_date' => 'de :date',
+ 'period_end_date' => 'até :date',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ro.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ro.php
index bd812f0..cc16724 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ro.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ro.php
@@ -1,4 +1,5 @@
'un an|:count ani|:count ani',
- 'month' => 'o lună|:count luni|:count luni',
- 'week' => 'o săptămână|:count săptămâni|:count săptămâni',
- 'day' => 'o zi|:count zile|:count zile',
- 'hour' => 'o oră|:count ore|:count ore',
- 'minute' => 'un minut|:count minute|:count minute',
- 'second' => 'o secundă|:count secunde|:count secunde',
- 'ago' => 'acum :time',
- 'from_now' => ':time de acum',
- 'after' => 'peste :time',
- 'before' => 'acum :time'
+ 'year' => 'un an|:count ani|:count ani',
+ 'y' => 'un an|:count ani|:count ani',
+ 'month' => 'o lună|:count luni|:count luni',
+ 'm' => 'o lună|:count luni|:count luni',
+ 'week' => 'o săptămână|:count săptămâni|:count săptămâni',
+ 'w' => 'o săptămână|:count săptămâni|:count săptămâni',
+ 'day' => 'o zi|:count zile|:count zile',
+ 'd' => 'o zi|:count zile|:count zile',
+ 'hour' => 'o oră|:count ore|:count ore',
+ 'h' => 'o oră|:count ore|:count ore',
+ 'minute' => 'un minut|:count minute|:count minute',
+ 'min' => 'un minut|:count minute|:count minute',
+ 'second' => 'o secundă|:count secunde|:count secunde',
+ 's' => 'o secundă|:count secunde|:count secunde',
+ 'ago' => 'acum :time',
+ 'from_now' => ':time de acum',
+ 'after' => 'peste :time',
+ 'before' => 'acum :time',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ru.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ru.php
index c843c35..6a83fb1 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/ru.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ru.php
@@ -1,4 +1,5 @@
':count год|:count года|:count лет',
- 'month' => ':count месяц|:count месяца|:count месяцев',
- 'week' => ':count неделю|:count недели|:count недель',
- 'day' => ':count день|:count дня|:count дней',
- 'hour' => ':count час|:count часа|:count часов',
- 'minute' => ':count минуту|:count минуты|:count минут',
- 'second' => ':count секунду|:count секунды|:count секунд',
- 'ago' => ':time назад',
- 'from_now' => 'через :time',
- 'after' => ':time после',
- 'before' => ':time до'
+ 'year' => ':count год|:count года|:count лет',
+ 'y' => ':count г|:count г|:count л',
+ 'month' => ':count месяц|:count месяца|:count месяцев',
+ 'm' => ':count м|:count м|:count м',
+ 'week' => ':count неделю|:count недели|:count недель',
+ 'w' => ':count н|:count н|:count н',
+ 'day' => ':count день|:count дня|:count дней',
+ 'd' => ':count д|:count д|:count д',
+ 'hour' => ':count час|:count часа|:count часов',
+ 'h' => ':count ч|:count ч|:count ч',
+ 'minute' => ':count минуту|:count минуты|:count минут',
+ 'min' => ':count мин|:count мин|:count мин',
+ 'second' => ':count секунду|:count секунды|:count секунд',
+ 's' => ':count с|:count с|:count с',
+ 'ago' => ':time назад',
+ 'from_now' => 'через :time',
+ 'after' => ':time после',
+ 'before' => ':time до',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sh.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sh.php
new file mode 100644
index 0000000..57f287a
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sh.php
@@ -0,0 +1,35 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+\Symfony\Component\Translation\PluralizationRules::set(function ($number) {
+ return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
+}, 'sh');
+
+return array(
+ 'year' => ':count godina|:count godine|:count godina',
+ 'y' => ':count godina|:count godine|:count godina',
+ 'month' => ':count mesec|:count meseca|:count meseci',
+ 'm' => ':count mesec|:count meseca|:count meseci',
+ 'week' => ':count nedelja|:count nedelje|:count nedelja',
+ 'w' => ':count nedelja|:count nedelje|:count nedelja',
+ 'day' => ':count dan|:count dana|:count dana',
+ 'd' => ':count dan|:count dana|:count dana',
+ 'hour' => ':count čas|:count časa|:count časova',
+ 'h' => ':count čas|:count časa|:count časova',
+ 'minute' => ':count minut|:count minuta|:count minuta',
+ 'min' => ':count minut|:count minuta|:count minuta',
+ 'second' => ':count sekund|:count sekunda|:count sekundi',
+ 's' => ':count sekund|:count sekunda|:count sekundi',
+ 'ago' => 'pre :time',
+ 'from_now' => 'za :time',
+ 'after' => 'nakon :time',
+ 'before' => ':time raniјe',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sk.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sk.php
index 8729e45..6101344 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/sk.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sk.php
@@ -1,4 +1,5 @@
'rok|:count roky|:count rokov',
- 'month' => 'mesiac|:count mesiace|:count mesiacov',
- 'week' => 'týždeň|:count týždne|:count týždňov',
- 'day' => 'deň|:count dni|:count dní',
- 'hour' => 'hodinu|:count hodiny|:count hodín',
- 'minute' => 'minútu|:count minúty|:count minút',
- 'second' => 'sekundu|:count sekundy|:count sekúnd',
- 'ago' => 'pred :time',
- 'from_now' => 'za :time',
- 'after' => ':time neskôr',
- 'before' => ':time predtým'
+ 'year' => 'rok|:count roky|:count rokov',
+ 'y' => 'rok|:count roky|:count rokov',
+ 'month' => 'mesiac|:count mesiace|:count mesiacov',
+ 'm' => 'mesiac|:count mesiace|:count mesiacov',
+ 'week' => 'týždeň|:count týždne|:count týždňov',
+ 'w' => 'týždeň|:count týždne|:count týždňov',
+ 'day' => 'deň|:count dni|:count dní',
+ 'd' => 'deň|:count dni|:count dní',
+ 'hour' => 'hodinu|:count hodiny|:count hodín',
+ 'h' => 'hodinu|:count hodiny|:count hodín',
+ 'minute' => 'minútu|:count minúty|:count minút',
+ 'min' => 'minútu|:count minúty|:count minút',
+ 'second' => 'sekundu|:count sekundy|:count sekúnd',
+ 's' => 'sekundu|:count sekundy|:count sekúnd',
+ 'ago' => 'pred :time',
+ 'from_now' => 'za :time',
+ 'after' => 'o :time neskôr',
+ 'before' => ':time predtým',
+ 'year_ago' => 'rokom|:count rokmi|:count rokmi',
+ 'month_ago' => 'mesiacom|:count mesiacmi|:count mesiacmi',
+ 'week_ago' => 'týždňom|:count týždňami|:count týždňami',
+ 'day_ago' => 'dňom|:count dňami|:count dňami',
+ 'hour_ago' => 'hodinou|:count hodinami|:count hodinami',
+ 'minute_ago' => 'minútou|:count minútami|:count minútami',
+ 'second_ago' => 'sekundou|:count sekundami|:count sekundami',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sl.php
index 8149a5d..06686d1 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/sl.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sl.php
@@ -1,4 +1,5 @@
':count leto|:count leti|:count leta|:count let',
- 'month' => ':count mesec|:count meseca|:count mesece|:count mesecev',
- 'week' => ':count teden|:count tedna|:count tedne|:count tednov',
- 'day' => ':count dan|:count dni|:count dni|:count dni',
- 'hour' => ':count uro|:count uri|:count ure|:count ur',
- 'minute' => ':count minuto|:count minuti|:count minute|:count minut',
- 'second' => ':count sekundo|:count sekundi|:count sekunde|:count sekund',
- 'year_ago' => ':count letom|:count leti|:count leti|:count leti',
+ 'year' => ':count leto|:count leti|:count leta|:count let',
+ 'y' => ':count leto|:count leti|:count leta|:count let',
+ 'month' => ':count mesec|:count meseca|:count mesece|:count mesecev',
+ 'm' => ':count mesec|:count meseca|:count mesece|:count mesecev',
+ 'week' => ':count teden|:count tedna|:count tedne|:count tednov',
+ 'w' => ':count teden|:count tedna|:count tedne|:count tednov',
+ 'day' => ':count dan|:count dni|:count dni|:count dni',
+ 'd' => ':count dan|:count dni|:count dni|:count dni',
+ 'hour' => ':count uro|:count uri|:count ure|:count ur',
+ 'h' => ':count uro|:count uri|:count ure|:count ur',
+ 'minute' => ':count minuto|:count minuti|:count minute|:count minut',
+ 'min' => ':count minuto|:count minuti|:count minute|:count minut',
+ 'second' => ':count sekundo|:count sekundi|:count sekunde|:count sekund',
+ 's' => ':count sekundo|:count sekundi|:count sekunde|:count sekund',
+ 'year_ago' => ':count letom|:count leti|:count leti|:count leti',
'month_ago' => ':count mesecem|:count meseci|:count meseci|:count meseci',
- 'week_ago' => ':count tednom|:count tednoma|:count tedni|:count tedni',
- 'day_ago' => ':count dnem|:count dnevoma|:count dnevi|:count dnevi',
- 'hour_ago' => ':count uro|:count urama|:count urami|:count urami',
- 'minute_ago'=> ':count minuto|:count minutama|:count minutami|:count minutami',
- 'second_ago'=> ':count sekundo|:count sekundama|:count sekundami|:count sekundami',
- 'ago' => 'pred :time',
- 'from_now' => 'čez :time',
- 'after' => 'čez :time',
- 'before' => 'pred :time'
+ 'week_ago' => ':count tednom|:count tednoma|:count tedni|:count tedni',
+ 'day_ago' => ':count dnem|:count dnevoma|:count dnevi|:count dnevi',
+ 'hour_ago' => ':count uro|:count urama|:count urami|:count urami',
+ 'minute_ago' => ':count minuto|:count minutama|:count minutami|:count minutami',
+ 'second_ago' => ':count sekundo|:count sekundama|:count sekundami|:count sekundami',
+ 'ago' => 'pred :time',
+ 'from_now' => 'čez :time',
+ 'after' => 'čez :time',
+ 'before' => 'pred :time',
+ 'diff_now' => 'ravnokar',
+ 'diff_yesterday' => 'včeraj',
+ 'diff_tomorrow' => 'jutri',
+ 'diff_before_yesterday' => 'predvčerajšnjim',
+ 'diff_after_tomorrow' => 'pojutrišnjem',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sq.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sq.php
index 4778260..6e138a0 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/sq.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sq.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => '1 vit|:count vjet',
- 'month' => '1 muaj|:count muaj',
- 'week' => '1 javë|:count javë',
- 'day' => '1 ditë|:count ditë',
- 'hour' => '1 orë|:count orë',
- 'minute' => '1 minutë|:count minuta',
- 'second' => '1 sekondë|:count sekonda',
- 'ago' => ':time më parë',
- 'from_now' => ':time nga tani',
- 'after' => ':time pas',
- 'before' => ':time para',
+ 'year' => ':count vit|:count vjet',
+ 'y' => ':count vit|:count vjet',
+ 'month' => ':count muaj|:count muaj',
+ 'm' => ':count muaj|:count muaj',
+ 'week' => ':count javë|:count javë',
+ 'w' => ':count javë|:count javë',
+ 'day' => ':count ditë|:count ditë',
+ 'd' => ':count ditë|:count ditë',
+ 'hour' => ':count orë|:count orë',
+ 'h' => ':count orë|:count orë',
+ 'minute' => ':count minutë|:count minuta',
+ 'min' => ':count minutë|:count minuta',
+ 'second' => ':count sekondë|:count sekonda',
+ 's' => ':count sekondë|:count sekonda',
+ 'ago' => ':time më parë',
+ 'from_now' => ':time nga tani',
+ 'after' => ':time pas',
+ 'before' => ':time para',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr.php
index af060fa..5a10642 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr.php
@@ -1,4 +1,5 @@
':count godina|:count godine|:count godina',
- 'month' => ':count mesec|:count meseca|:count meseci',
- 'week' => ':count nedelja|:count nedelje|:count nedelja',
- 'day' => ':count dan|:count dana|:count dana',
- 'hour' => ':count sat|:count sata|:count sati',
- 'minute' => ':count minut|:count minuta |:count minuta',
- 'second' => ':count sekund|:count sekunde|:count sekunde',
- 'ago' => 'pre :time',
- 'from_now' => ':time od sada',
- 'after' => 'nakon :time',
- 'before' => 'pre :time'
+ 'year' => ':count godina|:count godine|:count godina',
+ 'y' => ':count godina|:count godine|:count godina',
+ 'month' => ':count mesec|:count meseca|:count meseci',
+ 'm' => ':count mesec|:count meseca|:count meseci',
+ 'week' => ':count nedelja|:count nedelje|:count nedelja',
+ 'w' => ':count nedelja|:count nedelje|:count nedelja',
+ 'day' => ':count dan|:count dana|:count dana',
+ 'd' => ':count dan|:count dana|:count dana',
+ 'hour' => ':count sat|:count sata|:count sati',
+ 'h' => ':count sat|:count sata|:count sati',
+ 'minute' => ':count minut|:count minuta |:count minuta',
+ 'min' => ':count minut|:count minuta |:count minuta',
+ 'second' => ':count sekund|:count sekunde|:count sekunde',
+ 's' => ':count sekund|:count sekunde|:count sekunde',
+ 'ago' => 'pre :time',
+ 'from_now' => ':time od sada',
+ 'after' => 'nakon :time',
+ 'before' => 'pre :time',
+
+ 'year_from_now' => '{1,21,31,41,51} :count godinu|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count godine|[5,Inf[ :count godina',
+ 'year_ago' => '{1,21,31,41,51} :count godinu|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count godine|[5,Inf[ :count godina',
+
+ 'week_from_now' => '{1} :count nedelju|{2,3,4} :count nedelje|[5,Inf[ :count nedelja',
+ 'week_ago' => '{1} :count nedelju|{2,3,4} :count nedelje|[5,Inf[ :count nedelja',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php
new file mode 100644
index 0000000..2db83ed
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl.php
@@ -0,0 +1,43 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[ :count година',
+ 'y' => ':count г.',
+ 'month' => '{1} :count месец|{2,3,4}:count месеца|[5,Inf[ :count месеци',
+ 'm' => ':count м.',
+ 'week' => '{1} :count недеља|{2,3,4}:count недеље|[5,Inf[ :count недеља',
+ 'w' => ':count нед.',
+ 'day' => '{1,21,31} :count дан|[2,Inf[ :count дана',
+ 'd' => ':count д.',
+ 'hour' => '{1,21} :count сат|{2,3,4,22,23,24}:count сата|[5,Inf[ :count сати',
+ 'h' => ':count ч.',
+ 'minute' => '{1,21,31,41,51} :count минут|[2,Inf[ :count минута',
+ 'min' => ':count мин.',
+ 'second' => '{1,21,31,41,51} :count секунд|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count секунде|[5,Inf[:count секунди',
+ 's' => ':count сек.',
+ 'ago' => 'пре :time',
+ 'from_now' => 'за :time',
+ 'after' => ':time након',
+ 'before' => ':time пре',
+
+ 'year_from_now' => '{1,21,31,41,51} :count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count године|[5,Inf[ :count година',
+ 'year_ago' => '{1,21,31,41,51} :count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count године|[5,Inf[ :count година',
+
+ 'week_from_now' => '{1} :count недељу|{2,3,4} :count недеље|[5,Inf[ :count недеља',
+ 'week_ago' => '{1} :count недељу|{2,3,4} :count недеље|[5,Inf[ :count недеља',
+
+ 'diff_now' => 'управо сада',
+ 'diff_yesterday' => 'јуче',
+ 'diff_tomorrow' => 'сутра',
+ 'diff_before_yesterday' => 'прекјуче',
+ 'diff_after_tomorrow' => 'прекосутра',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php
new file mode 100644
index 0000000..18214c4
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Cyrl_ME.php
@@ -0,0 +1,43 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count године|[0,Inf[ :count година',
+ 'y' => ':count г.',
+ 'month' => '{1} :count мјесец|{2,3,4}:count мјесеца|[5,Inf[ :count мјесеци',
+ 'm' => ':count мј.',
+ 'week' => '{1} :count недјеља|{2,3,4}:count недјеље|[5,Inf[ :count недјеља',
+ 'w' => ':count нед.',
+ 'day' => '{1,21,31} :count дан|[2,Inf[ :count дана',
+ 'd' => ':count д.',
+ 'hour' => '{1,21} :count сат|{2,3,4,22,23,24}:count сата|[5,Inf[ :count сати',
+ 'h' => ':count ч.',
+ 'minute' => '{1,21,31,41,51} :count минут|[2,Inf[ :count минута',
+ 'min' => ':count мин.',
+ 'second' => '{1,21,31,41,51} :count секунд|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count секунде|[5,Inf[:count секунди',
+ 's' => ':count сек.',
+ 'ago' => 'прије :time',
+ 'from_now' => 'за :time',
+ 'after' => ':time након',
+ 'before' => ':time прије',
+
+ 'year_from_now' => '{1,21,31,41,51} :count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count године|[5,Inf[ :count година',
+ 'year_ago' => '{1,21,31,41,51} :count годину|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count године|[5,Inf[ :count година',
+
+ 'week_from_now' => '{1} :count недјељу|{2,3,4} :count недјеље|[5,Inf[ :count недјеља',
+ 'week_ago' => '{1} :count недјељу|{2,3,4} :count недјеље|[5,Inf[ :count недјеља',
+
+ 'diff_now' => 'управо сада',
+ 'diff_yesterday' => 'јуче',
+ 'diff_tomorrow' => 'сутра',
+ 'diff_before_yesterday' => 'прекјуче',
+ 'diff_after_tomorrow' => 'прекосјутра',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php
new file mode 100644
index 0000000..2d2e288
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_Latn_ME.php
@@ -0,0 +1,43 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => '{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count godine|[0,Inf[ :count godina',
+ 'y' => ':count g.',
+ 'month' => '{1} :count mjesec|{2,3,4}:count mjeseca|[5,Inf[ :count mjeseci',
+ 'm' => ':count mj.',
+ 'week' => '{1} :count nedjelja|{2,3,4}:count nedjelje|[5,Inf[ :count nedjelja',
+ 'w' => ':count ned.',
+ 'day' => '{1,21,31} :count dan|[2,Inf[ :count dana',
+ 'd' => ':count d.',
+ 'hour' => '{1,21} :count sat|{2,3,4,22,23,24}:count sata|[5,Inf[ :count sati',
+ 'h' => ':count č.',
+ 'minute' => '{1,21,31,41,51} :count minut|[2,Inf[ :count minuta',
+ 'min' => ':count min.',
+ 'second' => '{1,21,31,41,51} :count sekund|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54}:count sekunde|[5,Inf[:count sekundi',
+ 's' => ':count sek.',
+ 'ago' => 'prije :time',
+ 'from_now' => 'za :time',
+ 'after' => ':time nakon',
+ 'before' => ':time prije',
+
+ 'year_from_now' => '{1,21,31,41,51} :count godinu|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count godine|[5,Inf[ :count godina',
+ 'year_ago' => '{1,21,31,41,51} :count godinu|{2,3,4,22,23,24,32,33,34,42,43,44,52,53,54} :count godine|[5,Inf[ :count godina',
+
+ 'week_from_now' => '{1} :count nedjelju|{2,3,4} :count nedjelje|[5,Inf[ :count nedjelja',
+ 'week_ago' => '{1} :count nedjelju|{2,3,4} :count nedjelje|[5,Inf[ :count nedjelja',
+
+ 'diff_now' => 'upravo sada',
+ 'diff_yesterday' => 'juče',
+ 'diff_tomorrow' => 'sutra',
+ 'diff_before_yesterday' => 'prekjuče',
+ 'diff_after_tomorrow' => 'preksutra',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_ME.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_ME.php
new file mode 100644
index 0000000..7ebf6f0
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sr_ME.php
@@ -0,0 +1,12 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return require __DIR__.'/sr_Latn_ME.php';
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sv.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sv.php
index 54f61fc..89a03b4 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/sv.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sv.php
@@ -1,4 +1,5 @@
'1 år|:count år',
- 'month' => '1 månad|:count månader',
- 'week' => '1 vecka|:count veckor',
- 'day' => '1 dag|:count dagar',
- 'hour' => '1 timme|:count timmar',
- 'minute' => '1 minut|:count minuter',
- 'second' => '1 sekund|:count sekunder',
- 'ago' => ':time sedan',
- 'from_now' => 'om :time',
- 'after' => ':time efter',
- 'before' => ':time före'
+ 'year' => ':count år|:count år',
+ 'y' => ':count år|:count år',
+ 'month' => ':count månad|:count månader',
+ 'm' => ':count månad|:count månader',
+ 'week' => ':count vecka|:count veckor',
+ 'w' => ':count vecka|:count veckor',
+ 'day' => ':count dag|:count dagar',
+ 'd' => ':count dag|:count dagar',
+ 'hour' => ':count timme|:count timmar',
+ 'h' => ':count timme|:count timmar',
+ 'minute' => ':count minut|:count minuter',
+ 'min' => ':count minut|:count minuter',
+ 'second' => ':count sekund|:count sekunder',
+ 's' => ':count sekund|:count sekunder',
+ 'ago' => ':time sedan',
+ 'from_now' => 'om :time',
+ 'after' => ':time efter',
+ 'before' => ':time före',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/sw.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/sw.php
new file mode 100644
index 0000000..52f0342
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/sw.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => 'mwaka 1|miaka :count',
+ 'y' => 'mwaka 1|miaka :count',
+ 'month' => 'mwezi 1|miezi :count',
+ 'm' => 'mwezi 1|miezi :count',
+ 'week' => 'wiki 1|wiki :count',
+ 'w' => 'wiki 1|wiki :count',
+ 'day' => 'siku 1|siku :count',
+ 'd' => 'siku 1|siku :count',
+ 'hour' => 'saa 1|masaa :count',
+ 'h' => 'saa 1|masaa :count',
+ 'minute' => 'dakika 1|dakika :count',
+ 'min' => 'dakika 1|dakika :count',
+ 'second' => 'sekunde 1|sekunde :count',
+ 's' => 'sekunde 1|sekunde :count',
+ 'ago' => ':time ziliyopita',
+ 'from_now' => ':time kwanzia sasa',
+ 'after' => ':time baada',
+ 'before' => ':time kabla',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/th.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/th.php
index 13459bc..88bb4ac 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/th.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/th.php
@@ -1,4 +1,5 @@
'1 ปี|:count ปี',
- 'month' => '1 เดือน|:count เดือน',
- 'week' => '1 สัปดาห์|:count สัปดาห์',
- 'day' => '1 วัน|:count วัน',
- 'hour' => '1 ชั่วโมง|:count ชั่วโมง',
- 'minute' => '1 นาที|:count นาที',
- 'second' => '1 วินาที|:count วินาที',
- 'ago' => ':time ที่แล้ว',
- 'from_now' => ':time จากนี้',
- 'after' => 'หลัง:time',
- 'before' => 'ก่อน:time'
+ 'year' => ':count ปี',
+ 'y' => ':count ปี',
+ 'month' => ':count เดือน',
+ 'm' => ':count เดือน',
+ 'week' => ':count สัปดาห์',
+ 'w' => ':count สัปดาห์',
+ 'day' => ':count วัน',
+ 'd' => ':count วัน',
+ 'hour' => ':count ชั่วโมง',
+ 'h' => ':count ชั่วโมง',
+ 'minute' => ':count นาที',
+ 'min' => ':count นาที',
+ 'second' => ':count วินาที',
+ 's' => ':count วินาที',
+ 'ago' => ':timeที่แล้ว',
+ 'from_now' => ':timeต่อจากนี้',
+ 'after' => ':timeหลังจากนี้',
+ 'before' => ':timeก่อน',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/tr.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/tr.php
index d7f5134..6a9dfed 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/tr.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/tr.php
@@ -9,20 +9,23 @@
* file that was distributed with this source code.
*/
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
return array(
- 'year' => ':count yıl',
- 'month' => ':count ay',
- 'week' => ':count hafta',
- 'day' => ':count gün',
- 'hour' => ':count saat',
- 'minute' => ':count dakika',
- 'second' => ':count saniye',
- 'ago' => ':time önce',
- 'from_now' => ':time andan itibaren',
- 'after' => ':time sonra',
- 'before' => ':time önce',
+ 'year' => ':count yıl',
+ 'y' => ':count yıl',
+ 'month' => ':count ay',
+ 'm' => ':count ay',
+ 'week' => ':count hafta',
+ 'w' => ':count hafta',
+ 'day' => ':count gün',
+ 'd' => ':count gün',
+ 'hour' => ':count saat',
+ 'h' => ':count saat',
+ 'minute' => ':count dakika',
+ 'min' => ':count dakika',
+ 'second' => ':count saniye',
+ 's' => ':count saniye',
+ 'ago' => ':time önce',
+ 'from_now' => ':time sonra',
+ 'after' => ':time sonra',
+ 'before' => ':time önce',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/uk.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/uk.php
index 6a23d27..8d08eaa 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/uk.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/uk.php
@@ -1,4 +1,5 @@
':count рік|:count роки|:count років',
- 'month' => ':count місяць|:count місяці|:count місяців',
- 'week' => ':count тиждень|:count тижні|:count тижнів',
- 'day' => ':count день|:count дні|:count днів',
- 'hour' => ':count година|:count години|:count годин',
- 'minute' => ':count хвилину|:count хвилини|:count хвилин',
- 'second' => ':count секунду|:count секунди|:count секунд',
- 'ago' => ':time назад',
- 'from_now' => 'через :time',
- 'after' => ':time після',
- 'before' => ':time до'
+ 'year' => ':count рік|:count роки|:count років',
+ 'y' => ':count рік|:count роки|:count років',
+ 'month' => ':count місяць|:count місяці|:count місяців',
+ 'm' => ':count місяць|:count місяці|:count місяців',
+ 'week' => ':count тиждень|:count тижні|:count тижнів',
+ 'w' => ':count тиждень|:count тижні|:count тижнів',
+ 'day' => ':count день|:count дні|:count днів',
+ 'd' => ':count день|:count дні|:count днів',
+ 'hour' => ':count година|:count години|:count годин',
+ 'h' => ':count година|:count години|:count годин',
+ 'minute' => ':count хвилину|:count хвилини|:count хвилин',
+ 'min' => ':count хвилину|:count хвилини|:count хвилин',
+ 'second' => ':count секунду|:count секунди|:count секунд',
+ 's' => ':count секунду|:count секунди|:count секунд',
+ 'ago' => ':time тому',
+ 'from_now' => 'через :time',
+ 'after' => ':time після',
+ 'before' => ':time до',
+ 'diff_now' => 'щойно',
+ 'diff_yesterday' => 'вчора',
+ 'diff_tomorrow' => 'завтра',
+ 'diff_before_yesterday' => 'позавчора',
+ 'diff_after_tomorrow' => 'післязавтра',
+ 'period_recurrences' => 'один раз|:count рази|:count разів',
+ 'period_interval' => 'кожні :interval',
+ 'period_start_date' => 'з :date',
+ 'period_end_date' => 'до :date',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/ur.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/ur.php
new file mode 100644
index 0000000..3c5f7ed
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/ur.php
@@ -0,0 +1,24 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count سال',
+ 'month' => ':count ماه',
+ 'week' => ':count ہفتے',
+ 'day' => ':count روز',
+ 'hour' => ':count گھنٹے',
+ 'minute' => ':count منٹ',
+ 'second' => ':count سیکنڈ',
+ 'ago' => ':time پہلے',
+ 'from_now' => ':time بعد',
+ 'after' => ':time بعد',
+ 'before' => ':time پہلے',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/uz.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/uz.php
index d9a5efa..1cb6f71 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/uz.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/uz.php
@@ -1,4 +1,5 @@
':count yil|:count yil|:count yil',
- 'month' => ':count oy|:count oy|:count oylar',
- 'week' => ':count hafta|:count hafta|:count hafta',
- 'day' => ':count kun|:count kun|:count kun',
- 'hour' => ':count soat|:count soat|:count soat',
- 'minute' => ':count minut|:count minut|:count minut',
- 'second' => ':count sekund|:count sekund|:count sekund',
- 'ago' => ':time avval',
- 'from_now' => 'keyin :time',
- 'after' => ':time keyin',
- 'before' => ':time gacha'
+ 'year' => ':count yil',
+ 'y' => ':count yil',
+ 'month' => ':count oy',
+ 'm' => ':count oy',
+ 'week' => ':count hafta',
+ 'w' => ':count hafta',
+ 'day' => ':count kun',
+ 'd' => ':count kun',
+ 'hour' => ':count soat',
+ 'h' => ':count soat',
+ 'minute' => ':count daqiqa',
+ 'min' => ':count daq',
+ 'second' => ':count soniya',
+ 's' => ':count s',
+ 'ago' => ':time avval',
+ 'from_now' => ':time dan keyin',
+ 'after' => ':time keyin',
+ 'before' => ':time oldin',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/vi.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/vi.php
index e0e8dfc..3f9838d 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/vi.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/vi.php
@@ -1,4 +1,5 @@
':count năm',
- 'month' => ':count tháng',
- 'week' => ':count tuần',
- 'day' => ':count ngày',
- 'hour' => ':count giờ',
- 'minute' => ':count phút',
- 'second' => ':count giây',
- 'ago' => ':time trước',
- 'from_now' => ':time từ bây giờ',
- 'after' => ':time sau',
- 'before' => ':time trước'
+ 'year' => ':count năm',
+ 'y' => ':count năm',
+ 'month' => ':count tháng',
+ 'm' => ':count tháng',
+ 'week' => ':count tuần',
+ 'w' => ':count tuần',
+ 'day' => ':count ngày',
+ 'd' => ':count ngày',
+ 'hour' => ':count giờ',
+ 'h' => ':count giờ',
+ 'minute' => ':count phút',
+ 'min' => ':count phút',
+ 'second' => ':count giây',
+ 's' => ':count giây',
+ 'ago' => ':time trước',
+ 'from_now' => ':time từ bây giờ',
+ 'after' => ':time sau',
+ 'before' => ':time trước',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/zh-TW.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/zh-TW.php
deleted file mode 100644
index 30f0825..0000000
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/zh-TW.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-/**
- * Translation messages. See http://symfony.com/doc/current/book/translation.html
- * for possible formats.
- */
-/**
- * Extracted from https://github.com/jenssegers/laravel-date/blob/master/src/lang/zh-TW/date.php
- */
-return array(
- 'year' => ':count 年',
- 'month' => ':count 月',
- 'week' => ':count 周',
- 'day' => ':count 天',
- 'hour' => ':count 小時',
- 'minute' => ':count 分鐘',
- 'second' => ':count 秒',
- 'ago' => ':time前',
- 'from_now' => '距現在 :time',
- 'after' => ':time後',
- 'before' => ':time前'
-);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/zh.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/zh.php
index 58ea74f..9e1f6ca 100644
--- a/application/vendor/nesbot/carbon/src/Carbon/Lang/zh.php
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/zh.php
@@ -1,4 +1,5 @@
':count年',
- 'month' => ':count月',
- 'week' => ':count周',
- 'day' => ':count天',
- 'hour' => ':count小时',
- 'minute' => ':count分钟',
- 'second' => ':count秒',
- 'ago' => ':time前',
- 'from_now' => ':time距现在',
- 'after' => ':time后',
- 'before' => ':time前'
+ 'year' => ':count年',
+ 'y' => ':count年',
+ 'month' => ':count个月',
+ 'm' => ':count个月',
+ 'week' => ':count周',
+ 'w' => ':count周',
+ 'day' => ':count天',
+ 'd' => ':count天',
+ 'hour' => ':count小时',
+ 'h' => ':count小时',
+ 'minute' => ':count分钟',
+ 'min' => ':count分钟',
+ 'second' => ':count秒',
+ 's' => ':count秒',
+ 'ago' => ':time前',
+ 'from_now' => '距现在:time',
+ 'after' => ':time后',
+ 'before' => ':time前',
);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Lang/zh_TW.php b/application/vendor/nesbot/carbon/src/Carbon/Lang/zh_TW.php
new file mode 100644
index 0000000..c848723
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Lang/zh_TW.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return array(
+ 'year' => ':count年',
+ 'y' => ':count年',
+ 'month' => ':count月',
+ 'm' => ':count月',
+ 'week' => ':count週',
+ 'w' => ':count週',
+ 'day' => ':count天',
+ 'd' => ':count天',
+ 'hour' => ':count小時',
+ 'h' => ':count小時',
+ 'minute' => ':count分鐘',
+ 'min' => ':count分鐘',
+ 'second' => ':count秒',
+ 's' => ':count秒',
+ 'ago' => ':time前',
+ 'from_now' => '距現在:time',
+ 'after' => ':time後',
+ 'before' => ':time前',
+);
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php b/application/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php
new file mode 100644
index 0000000..4d83b0c
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Laravel/ServiceProvider.php
@@ -0,0 +1,37 @@
+app['events'];
+ if ($events instanceof EventDispatcher || $events instanceof Dispatcher) {
+ $events->listen(class_exists('Illuminate\Foundation\Events\LocaleUpdated') ? 'Illuminate\Foundation\Events\LocaleUpdated' : 'locale.changed', function () use ($service) {
+ $service->updateLocale();
+ });
+ $service->updateLocale();
+ }
+ }
+
+ public function updateLocale()
+ {
+ $translator = $this->app['translator'];
+ if ($translator instanceof Translator || $translator instanceof IlluminateTranslator) {
+ Carbon::setLocale($translator->getLocale());
+ }
+ }
+
+ public function register()
+ {
+ // Needed for Laravel < 5.3 compatibility
+ }
+}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Translator.php b/application/vendor/nesbot/carbon/src/Carbon/Translator.php
new file mode 100644
index 0000000..12115b0
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Translator.php
@@ -0,0 +1,143 @@
+addLoader('array', new Translation\Loader\ArrayLoader());
+ parent::__construct($locale, $formatter, $cacheDir, $debug);
+ }
+
+ /**
+ * Reset messages of a locale (all locale if no locale passed).
+ * Remove custom messages and reload initial messages from matching
+ * file in Lang directory.
+ *
+ * @param string|null $locale
+ *
+ * @return bool
+ */
+ public function resetMessages($locale = null)
+ {
+ if ($locale === null) {
+ static::$messages = array();
+
+ return true;
+ }
+
+ if (file_exists($filename = __DIR__.'/Lang/'.$locale.'.php')) {
+ static::$messages[$locale] = require $filename;
+ $this->addResource('array', static::$messages[$locale], $locale);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Init messages language from matching file in Lang directory.
+ *
+ * @param string $locale
+ *
+ * @return bool
+ */
+ protected function loadMessagesFromFile($locale)
+ {
+ if (isset(static::$messages[$locale])) {
+ return true;
+ }
+
+ return $this->resetMessages($locale);
+ }
+
+ /**
+ * Set messages of a locale and take file first if present.
+ *
+ * @param string $locale
+ * @param array $messages
+ *
+ * @return $this
+ */
+ public function setMessages($locale, $messages)
+ {
+ $this->loadMessagesFromFile($locale);
+ $this->addResource('array', $messages, $locale);
+ static::$messages[$locale] = array_merge(
+ isset(static::$messages[$locale]) ? static::$messages[$locale] : array(),
+ $messages
+ );
+
+ return $this;
+ }
+
+ /**
+ * Get messages of a locale, if none given, return all the
+ * languages.
+ *
+ * @param string|null $locale
+ *
+ * @return array
+ */
+ public function getMessages($locale = null)
+ {
+ return $locale === null ? static::$messages : static::$messages[$locale];
+ }
+
+ /**
+ * Set the current translator locale and indicate if the source locale file exists
+ *
+ * @param string $locale locale ex. en
+ *
+ * @return bool
+ */
+ public function setLocale($locale)
+ {
+ $locale = preg_replace_callback('/[-_]([a-z]{2,})/', function ($matches) {
+ // _2-letters is a region, _3+-letters is a variant
+ return '_'.call_user_func(strlen($matches[1]) > 2 ? 'ucfirst' : 'strtoupper', $matches[1]);
+ }, strtolower($locale));
+
+ if ($this->loadMessagesFromFile($locale)) {
+ parent::setLocale($locale);
+
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/application/vendor/nesbot/carbon/src/Carbon/Upgrade.php b/application/vendor/nesbot/carbon/src/Carbon/Upgrade.php
new file mode 100644
index 0000000..26449ff
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/Carbon/Upgrade.php
@@ -0,0 +1,150 @@
+ '5.8.0',
+ 'laravel/cashier' => '9.0.1',
+ 'illuminate/support' => '5.8.0',
+ 'laravel/dusk' => '5.0.0',
+ );
+
+ protected static $otherLibraries = array(
+ 'spatie/laravel-analytics' => '3.6.4',
+ 'jenssegers/date' => '3.5.0',
+ );
+
+ /**
+ * @param \UpdateHelper\UpdateHelper $helper
+ */
+ public function check(UpdateHelper $helper)
+ {
+ $helper->write(array(
+ 'Carbon 1 is deprecated, see how to migrate to Carbon 2.',
+ 'https://carbon.nesbot.com/docs/#api-carbon-2',
+ ));
+
+ if (static::SUGGEST_ON_UPDATE || static::ASK_ON_UPDATE || $helper->getIo()->isVerbose()) {
+ $laravelUpdate = array();
+
+ foreach (static::$laravelLibraries as $name => $version) {
+ if ($helper->hasAsDependency($name) && $helper->isDependencyLesserThan($name, $version)) {
+ $laravelUpdate[$name] = $version;
+ }
+ }
+
+ if (count($laravelUpdate)) {
+ $output = array(
+ ' Please consider upgrading your Laravel dependencies to be compatible with Carbon 2:',
+ );
+
+ foreach ($laravelUpdate as $name => $version) {
+ $output[] = " - $name at least to version $version";
+ }
+
+ $output[] = '';
+ $output[] = " If you can't update Laravel, check https://carbon.nesbot.com/ to see how to";
+ $output[] = ' install Carbon 2 using alias version and our adapter kylekatarnls/laravel-carbon-2';
+ $output[] = '';
+
+ $helper->write($output);
+ }
+
+ foreach (static::$otherLibraries as $name => $version) {
+ if ($helper->hasAsDependency($name) && $helper->isDependencyLesserThan($name, $version)) {
+ $helper->write(" Please consider upgrading $name at least to $version to be compatible with Carbon 2.\n");
+ }
+ }
+
+ if (static::ASK_ON_UPDATE) {
+ static::askForUpgrade($helper);
+
+ return;
+ }
+ }
+
+ $path = implode(DIRECTORY_SEPARATOR, array('.', 'vendor', 'bin', 'upgrade-carbon'));
+
+ if (!file_exists($path)) {
+ $path = realpath(__DIR__.'/../../bin/upgrade-carbon');
+ }
+
+ $helper->write(
+ ' You can run '.escapeshellarg($path).
+ ' to get help in updating carbon and other frameworks and libraries that depend on it.'
+ );
+ }
+
+ private static function getUpgradeQuestion($upgrades)
+ {
+ $message = "Do you want us to try the following upgrade:\n";
+
+ foreach ($upgrades as $name => $version) {
+ $message .= " - $name: $version\n";
+ }
+
+ return $message.'[Y/N] ';
+ }
+
+ public static function askForUpgrade(UpdateHelper $helper, $upgradeIfNotInteractive = false)
+ {
+ $upgrades = array(
+ 'nesbot/carbon' => '^2.0.0',
+ );
+
+ foreach (array(static::$laravelLibraries, static::$otherLibraries) as $libraries) {
+ foreach ($libraries as $name => $version) {
+ if ($helper->hasAsDependency($name) && $helper->isDependencyLesserThan($name, $version)) {
+ $upgrades[$name] = "^$version";
+ }
+ }
+ }
+
+ $shouldUpgrade = $helper->isInteractive()
+ ? $helper->getIo()->askConfirmation(static::getUpgradeQuestion($upgrades))
+ : $upgradeIfNotInteractive;
+
+ if ($shouldUpgrade) {
+ $helper->setDependencyVersions($upgrades)->update();
+ }
+ }
+
+ public static function upgrade(ScriptEvent $event = null)
+ {
+ if (!$event) {
+ $composer = new Composer();
+ $baseDir = __DIR__.'/../..';
+
+ if (file_exists("$baseDir/autoload.php")) {
+ $baseDir .= '/..';
+ }
+
+ $composer->setConfig(new Config(true, $baseDir));
+ $event = new ScriptEvent(
+ 'upgrade-carbon',
+ $composer,
+ new ConsoleIO(new StringInput(''), new ConsoleOutput(), new HelperSet(array(
+ new QuestionHelper(),
+ )))
+ );
+ }
+
+ static::askForUpgrade(new UpdateHelper($event), true);
+ }
+}
diff --git a/application/vendor/nesbot/carbon/src/JsonSerializable.php b/application/vendor/nesbot/carbon/src/JsonSerializable.php
new file mode 100644
index 0000000..d34060b
--- /dev/null
+++ b/application/vendor/nesbot/carbon/src/JsonSerializable.php
@@ -0,0 +1,18 @@
+json_encode,
+ * which is a value of any type other than a resource.
+ *
+ * @since 5.4.0
+ */
+ public function jsonSerialize();
+ }
+}
diff --git a/application/vendor/nikic/php-parser/.gitignore b/application/vendor/nikic/php-parser/.gitignore
new file mode 100644
index 0000000..8c7db2a
--- /dev/null
+++ b/application/vendor/nikic/php-parser/.gitignore
@@ -0,0 +1,4 @@
+vendor/
+composer.lock
+grammar/kmyacc.exe
+grammar/y.output
diff --git a/application/vendor/nikic/php-parser/.travis.yml b/application/vendor/nikic/php-parser/.travis.yml
index 445913f..4716915 100644
--- a/application/vendor/nikic/php-parser/.travis.yml
+++ b/application/vendor/nikic/php-parser/.travis.yml
@@ -1,14 +1,32 @@
language: php
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.composer/cache
+
php:
- - 5.3
- 5.4
- 5.5
- 5.6
- 7.0
+ - nightly
- hhvm
+install:
+ - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then composer require satooshi/php-coveralls '~1.0'; fi
+ - composer install --prefer-dist
+
matrix:
allow_failures:
- - php: 7.0
+ - php: nightly
fast_finish: true
+
+script:
+ - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; else vendor/bin/phpunit; fi
+ - if [ $TRAVIS_PHP_VERSION = '7.0' ]; then test_old/run-php-src.sh; fi
+
+after_success:
+ if [ $TRAVIS_PHP_VERSION = '5.6' ]; then php vendor/bin/coveralls; fi
+
diff --git a/application/vendor/nikic/php-parser/CHANGELOG.md b/application/vendor/nikic/php-parser/CHANGELOG.md
index 75605cc..0ae6b7e 100644
--- a/application/vendor/nikic/php-parser/CHANGELOG.md
+++ b/application/vendor/nikic/php-parser/CHANGELOG.md
@@ -1,253 +1,151 @@
-Version 1.4.2-dev
+Version 2.1.2-dev
-----------------
Nothing yet.
-Version 1.4.1 (2015-09-19)
+Version 2.1.1 (2016-09-16)
--------------------------
-### Fixed
+### Changed
-* Fixed issue with too many newlines being stripped at the end of heredoc/nowdoc strings in some
- cases. (#227)
+* The pretty printer will now escape all control characters in the range `\x00-\x1F` inside double
+ quoted strings. If no special escape sequence is available, an octal escape will be used.
+* The quality of the error recovery has been improved. In particular unterminated expressions should
+ be handled more gracefully.
+* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments.
+* Comments on free-standing code blocks will no be retained as comments on the first statement in
+ the code block.
-Version 1.4.0 (2015-07-14)
+Version 2.1.0 (2016-04-19)
--------------------------
-### Added
-
-* Added interface `PhpParser\Node\FunctionLike`, which is implemented by `Stmt\ClassMethod`,
- `Stmt\Function_` and `Expr\Closure` nodes. This interface provides getters for their common
- subnodes.
-* Added `Node\Stmt\ClassLike::getMethod()` to look up a specific method on a class/interface/trait.
-
### Fixed
-* Fixed `isPublic()` return value for implicitly public properties and methods that define and
- additional modifier like `static` or `abstract`.
-* Properties are now accepted by the trait builder.
-* Fixed `__HALT_COMPILER_OFFSET__` support on HHVM.
-
-Version 1.3.0 (2015-05-02)
---------------------------
+* Properly support `B""` strings (with uppercase `B`) in a number of places.
+* Fixed reformatting of indented parts in a certain non-standard comment style.
### Added
-* Errors can now store the attributes of the node/token where the error occurred. Previously only the start line was
- stored.
-* If file positions are enabled in the lexer, errors can now provide column information if it is available. See
- [documentation](https://github.com/nikic/PHP-Parser/blob/master/doc/component/Error.markdown#column-information).
-* The parser now provides an experimental error recovery mode, which can be enabled by disabling the `throwOnError`
- parser option. In this mode the parser will try to construct a partial AST even if the code is not valid PHP. See
- [documentation](https://github.com/nikic/PHP-Parser/blob/master/doc/component/Error.markdown#error-recovery).
-* Added support for PHP 7 `yield from` expression. It is represented by `Expr\YieldFrom`.
-* Added support for PHP 7 anonymous classes. These are represented by ordinary `Stmt\Class_` nodes with the name set to
- `null`. Furthermore this implies that `Expr\New_` can now contain a `Stmt\Class_` in its `class` subnode.
-
-### Fixed
-
-* Fixed registration of PHP 7 aliases, for the case where the old name was used before the new name.
-* Fixed handling of precedence when pretty-printing `print` expressions.
-* Floating point numbers are now pretty-printed with a higher precision.
-* Checks for special class names like `self` are now case-insensitive.
-
-Version 1.2.2 (2015-04-03)
---------------------------
-
-* The `NameResolver` now resolves parameter type hints when entering the function/method/closure node. As such other
- visitors running after it will be able to make use of the resolved names at that point already.
-* The autoloader no longer sets the `unserialize_callback_func` ini option on registration - this is not necessary and
- may cause issues when running PhpUnit tests with process isolation.
-
-Version 1.2.1 (2015-03-24)
---------------------------
-
-* Fixed registration of the aliases introduced in 1.2.0. Previously the old class names could not be used in
- `instanceof` checks under some circumstances.
-
-Version 1.2.0 (2015-03-22)
---------------------------
+* Added `dumpComments` option to node dumper, to enable dumping of comments associated with nodes.
+* Added `Stmt\Nop` node, that is used to collect comments located at the end of a block or at the
+ end of a file (without a following node with which they could otherwise be associated).
+* Added `kind` attribute to `Expr\Exit` to distinguish between `exit` and `die`.
+* Added `kind` attribute to `Scalar\LNumber` to distinguish between decimal, binary, octal and
+ hexadecimal numbers.
+* Added `kind` attribtue to `Expr\Array` to distinguish between `array()` and `[]`.
+* Added `kind` attribute to `Scalar\String` and `Scalar\Encapsed` to distinguish between
+ single-quoted, double-quoted, heredoc and nowdoc string.
+* Added `docLabel` attribute to `Scalar\String` and `Scalar\Encapsed`, if it is a heredoc or
+ nowdoc string.
+* Added start file offset information to `Comment` nodes.
+* Added `setReturnType()` method to function and method builders.
+* Added `-h` and `--help` options to `php-parse` script.
### Changed
-* To ensure compatibility with PHP 7, the following node classes have been renamed:
-
- OLD => NEW
- PhpParser\Node\Expr\Cast\Bool => PhpParser\Node\Expr\Cast\Bool_
- PhpParser\Node\Expr\Cast\Int => PhpParser\Node\Expr\Cast\Int_
- PhpParser\Node\Expr\Cast\Object => PhpParser\Node\Expr\Cast\Object_
- PhpParser\Node\Expr\Cast\String => PhpParser\Node\Expr\Cast\String_
- PhpParser\Node\Scalar\String => PhpParser\Node\Scalar\String_
-
- **The previous class names are still supported as aliases.** However it is strongly encouraged to use the new names
- in order to make your code compatible with PHP 7.
-
-* Subnodes are now stored using real properties instead of an array. This improves performance and memory usage of the
- initial parse and subsequent node tree operations. The `NodeAbstract` class still supports the old way of specifying
- subnodes, however this is *deprecated*. In any case properties that are assigned to a node after creation will no
- longer be considered as subnodes.
-
-* Methods and property declarations will no longer set the `Stmt\Class_::MODIFIER_PUBLIC` flag if no visibility is
- explicitly given. However the `isPublic()` method will continue to return true. This allows you to distinguish whether
- a method/property is explicitly or implicitly public and control the pretty printer output more precisely.
-
-* The `Stmt\Class_`, `Stmt\Interface_` and `Stmt\Trait_` nodes now inherit from `Stmt\ClassLike`, which provides a
- `getMethods()` method. Previously this method was only available on `Stmt\Class_`.
-
-* Support including the `bootstrap.php` file multiple times.
-
-* Make documentation and tests part of the release tarball again.
-
-* Improve support for HHVM and PHP 7.
-
-### Added
-
-* Added support for PHP 7 return type declarations. This adds an additional `returnType` subnode to `Stmt\Function_`,
- `Stmt\ClassMethod` and `Expr\Closure`.
-
-* Added support for the PHP 7 null coalesce operator `??`. The operator is represented by `Expr\BinaryOp\Coalesce`.
-
-* Added support for the PHP 7 spaceship operator `<=>`. The operator is represented by `Expr\BinaryOp\Spaceship`.
-
-* Added use builder.
-
-* Added global namespace support to the namespace builder.
-
-* Added a constructor flag to `NodeTraverser`, which disables cloning of nodes.
+* Invalid octal literals now throw a parse error in PHP 7 mode.
+* The pretty printer takes all the new attributes mentioned in the previous section into account.
+* The protected `AbstractPrettyPrinter::pComments()` method no longer returns a trailing newline.
+* The bundled autoloader supports library files being stored in a different directory than
+ `PhpParser` for easier downstream distribution.
-Version 1.1.0 (2015-01-18)
---------------------------
-
-* Methods that do not specify an explicit visibility (e.g. `function method()`) will now have the `MODIFIER_PUBLIC`
- flag set. This also means that their `isPublic()` method will return true.
-
-* Declaring a property as abstract or final is now an error.
-
-* The `Lexer` and `Lexer\Emulative` classes now accept an `$options` array in their constructors. Currently only the
- `usedAttributes` option is supported, which determines which attributes will be added to AST nodes. In particular
- it is now possible to add information on the token and file positions corresponding to a node. For more details see
- the [Lexer component](https://github.com/nikic/PHP-Parser/blob/master/doc/component/Lexer.markdown) documentation.
-
-* Node visitors can now return `NodeTraverser::DONT_TRAVERSE_CHILDREN` from `enterNode()` in order to skip all children
- of the current node, for all visitors.
-
-* Added builders for traits and namespaces.
-
-* The class, interface, trait, function, method and property builders now support adding doc comments using the
- `setDocComment()` method.
-
-* Added support for fully-qualified and namespace-relative names in builders. No longer allow use of name component
- arrays.
-
-* Do not add documentation and tests to distribution archive files.
+### Deprecated
-Version 1.0.2 (2014-11-04)
---------------------------
+* The `Comment::setLine()` and `Comment::setText()` methods have been deprecated. Construct new
+ objects instead.
-* The `NameResolver` visitor now also resolves names in trait adaptations (aliases and precedence declarations).
+### Removed
-* Remove stray whitespace when pretty-printing trait adaptations that only change visibility.
+* The internal (but public) method `Scalar\LNumber::parse()` has been removed. A non-internal
+ `LNumber::fromString()` method has been added instead.
-Version 1.0.1 (2014-10-14)
+Version 2.0.1 (2016-02-28)
--------------------------
-* Disallow `new` expressions without a class name. Previously `new;` was accidentally considered to be valid code.
-
-* Support T_ONUMBER token used by HHVM.
-
-* Add ability to directly pass code to the `php-parse.php` script.
-
-* Prevent truncation of `var_dump()` output in the `php-parse.php` script if XDebug is used.
+### Fixed
-Version 1.0.0 (2014-09-12)
+* `declare() {}` and `declare();` are not semantically equivalent and will now result in different
+ ASTs. The format case will have an empty `stmts` array, while the latter will set `stmts` to
+ `null`.
+* Magic constants are now supported as semi-reserved keywords.
+* A shebang line like `#!/usr/bin/env php` is now allowed at the start of a namespaced file.
+ Previously this generated an exception.
+* The `prettyPrintFile()` method will not strip a trailing `?>` from the raw data that follows a
+ `__halt_compiler()` statement.
+* The `prettyPrintFile()` method will not strip an opening `cond`
- will now appear before `Stmt\If->stmts` etc.
+A more detailed description of backwards incompatible changes can be found in the
+[upgrading guide](UPGRADE-2.0.md).
-* Added `Scalar\MagicConstant->getName()`, which returns the name of the magic constant (e.g. `__CLASS__`).
+### Removed
-**The following changes are also included in 0.9.5**:
+* Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2 and PHP 5.3
+ code while running on a newer version.
+* Removed legacy class name aliases. This includes the old non-namespaced class names and the old
+ names for classes that were renamed for PHP 7 compatibility.
+* Removed support for legacy node format. All nodes must have a `getSubNodeNames()` method now.
-* [BC] Deprecated `PHPParser_Template` and `PHPParser_TemplateLoader`. This functionality does not belong in the main project
- and - as far as I know - nobody is using it.
+### Added
-* Add `NodeTraverser::removeVisitor()` method, which removes a visitor from the node traverser. This also modifies the
- corresponding `NodeTraverserInterface`.
+* Added support for remaining PHP 7 features that were not present in 1.x:
+ * Group use declarations. These are represented using `Stmt\GroupUse` nodes. Furthermore a `type`
+ attribute was added to `Stmt\UseUse` to handle mixed group use declarations.
+ * Uniform variable syntax.
+ * Generalized yield operator.
+ * Scalar type declarations. These are presented using `'bool'`, `'int'`, `'float'` and `'string'`
+ as the type. The PHP 5 parser also accepts these, however they'll be `Name` instances there.
+ * Unicode escape sequences.
+* Added `PhpParser\ParserFactory` class, which should be used to create parser instances.
+* Added `Name::concat()` which concatenates two names.
+* Added `Name->slice()` which takes a subslice of a name.
-* Fix alias resolution in `NameResolver`: Class names are now correctly handled as case-insensitive.
+### Changed
-* The undefined variable error, which is used to the lexer to reset the error state, will no longer interfere with
- custom error handlers.
+* `PhpParser\Parser` is now an interface, implemented by `Parser\Php5`, `Parser\Php7` and
+ `Parser\Multiple`. The `Multiple` parser will try multiple parsers, until one succeeds.
+* Token constants are now defined on `PhpParser\Parser\Tokens` rather than `PhpParser\Parser`.
+* The `Name->set()`, `Name->append()`, `Name->prepend()` and `Name->setFirst()` methods are
+ deprecated in favor of `Name::concat()` and `Name->slice()`.
+* The `NodeTraverser` no longer clones nodes by default. The old behavior can be restored by
+ passing `true` to the constructor.
+* The constructor for `Scalar` nodes no longer has a default value. E.g. `new LNumber()` should now
+ be written as `new LNumber(0)`.
---
-**This changelog only includes changes from the 1.0 series. For older changes see the [0.9 series changelog][1].**
-
- [1]: https://github.com/nikic/PHP-Parser/blob/0.9/CHANGELOG.md
+**This changelog only includes changes from the 2.0 series. For older changes see the
+[1.x series changelog](https://github.com/nikic/PHP-Parser/blob/1.x/CHANGELOG.md) and the
+[0.9 series changelog](https://github.com/nikic/PHP-Parser/blob/0.9/CHANGELOG.md).**
\ No newline at end of file
diff --git a/application/vendor/nikic/php-parser/README.md b/application/vendor/nikic/php-parser/README.md
index 729e19b..28c565c 100644
--- a/application/vendor/nikic/php-parser/README.md
+++ b/application/vendor/nikic/php-parser/README.md
@@ -1,12 +1,14 @@
PHP Parser
==========
-This is a PHP 5.2 to PHP 5.6 parser written in PHP. Its purpose is to simplify static code analysis and
+[![Build Status](https://travis-ci.org/nikic/PHP-Parser.svg?branch=master)](https://travis-ci.org/nikic/PHP-Parser) [![Coverage Status](https://coveralls.io/repos/github/nikic/PHP-Parser/badge.svg?branch=master)](https://coveralls.io/github/nikic/PHP-Parser?branch=master)
+
+This is a PHP 5.2 to PHP 7.0 parser written in PHP. Its purpose is to simplify static code analysis and
manipulation.
-[**Documentation for version 1.x**][doc_1_x] (stable; for running on PHP >= 5.3).
+[**Documentation for version 2.x**][doc_master] (stable; for running on PHP >= 5.4; for parsing PHP 5.2 to PHP 7.0).
-[Documentation for version 0.9.x][doc_0_9] (unsupported; for running on PHP 5.2).
+[Documentation for version 1.x][doc_1_x] (unsupported; for running on PHP >= 5.3; for parsing PHP 5.2 to PHP 5.6).
In a Nutshell
-------------
@@ -70,18 +72,25 @@ programming errors or security issues).
Additionally, you can convert a syntax tree back to PHP code. This allows you to do code preprocessing
(like automatedly porting code to older PHP versions).
+Installation
+------------
+
+The preferred installation method is [composer](https://getcomposer.org):
+
+ php composer.phar require nikic/php-parser
+
Documentation
-------------
1. [Introduction](doc/0_Introduction.markdown)
- 2. [Installation](doc/1_Installation.markdown)
- 3. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
- 4. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
- 5. [Code generation](doc/4_Code_generation.markdown)
+ 2. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
+ 3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
+ 4. [Code generation](doc/4_Code_generation.markdown)
Component documentation:
- 1. [Lexer](doc/component/Lexer.markdown)
+ 1. [Error](doc/component/Error.markdown)
+ 2. [Lexer](doc/component/Lexer.markdown)
- [doc_0_9]: https://github.com/nikic/PHP-Parser/tree/0.9/doc
[doc_1_x]: https://github.com/nikic/PHP-Parser/tree/1.x/doc
+ [doc_master]: https://github.com/nikic/PHP-Parser/tree/master/doc
diff --git a/application/vendor/nikic/php-parser/UPGRADE-2.0.md b/application/vendor/nikic/php-parser/UPGRADE-2.0.md
new file mode 100644
index 0000000..1c61de5
--- /dev/null
+++ b/application/vendor/nikic/php-parser/UPGRADE-2.0.md
@@ -0,0 +1,74 @@
+Upgrading from PHP-Parser 1.x to 2.0
+====================================
+
+### PHP version requirements
+
+PHP-Parser now requires PHP 5.4 or newer to run. It is however still possible to *parse* PHP 5.2 and
+PHP 5.3 source code, while running on a newer version.
+
+### Creating a parser instance
+
+Parser instances should now be created through the `ParserFactory`. Old direct instantiation code
+will not work, because the parser class was renamed.
+
+Old:
+
+```php
+use PhpParser\Parser, PhpParser\Lexer;
+$parser = new Parser(new Lexer\Emulative);
+```
+
+New:
+
+```php
+use PhpParser\ParserFactory;
+$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
+```
+
+The first argument to `ParserFactory` determines how different PHP versions are handled. The
+possible values are:
+
+ * `ParserFactory::PREFER_PHP7`: Try to parse code as PHP 7. If this fails, try to parse it as PHP 5.
+ * `ParserFactory::PREFER_PHP5`: Try to parse code as PHP 5. If this fails, try to parse it as PHP 7.
+ * `ParserFactory::ONLY_PHP7`: Parse code as PHP 7.
+ * `ParserFactory::ONLY_PHP5`: Parse code as PHP 5.
+
+For most practical purposes the difference between `PREFER_PHP7` and `PREFER_PHP5` is mainly whether
+a scalar type hint like `string` will be stored as `'string'` (PHP 7) or as `new Name('string')`
+(PHP 5).
+
+To use a custom lexer, pass it as the second argument to the `create()` method:
+
+```php
+use PhpParser\ParserFactory;
+$lexer = new MyLexer;
+$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7, $lexer);
+```
+
+### Rename of the `PhpParser\Parser` class
+
+`PhpParser\Parser` is now an interface, which is implemented by `Parser\Php5`, `Parser\Php7` and
+`Parser\Multiple`. Parser tokens are now defined in `Parser\Tokens`. If you use the `ParserFactory`
+described above to create your parser instance, these changes should have no further impact on you.
+
+### Removal of legacy aliases
+
+All legacy aliases for classes have been removed. This includes the old non-namespaced `PHPParser_`
+classes, as well as the classes that had to be renamed for PHP 7 support.
+
+### Deprecations
+
+The `set()`, `setFirst()`, `append()` and `prepend()` methods of the `Node\Name` class have been
+deprecated. Instead `Name::concat()` and `Name->slice()` should be used.
+
+### Miscellaneous
+
+* The `NodeTraverser` no longer clones nodes by default. If you want to restore the old behavior,
+ pass `true` to the constructor.
+* The legacy node format has been removed. If you use custom nodes, they are now expected to
+ implement a `getSubNodeNames()` method.
+* The default value for `Scalar` node constructors was removed. This means that something like
+ `new LNumber()` should be replaced by `new LNumber(0)`.
+* String parts of encapsed strings are now represented using `Scalar\EncapsStringPart` nodes, while
+ previously raw strings were used. This affects the `parts` child of `Scalar\Encaps` and
+ `Expr\ShellExec`.
\ No newline at end of file
diff --git a/application/vendor/nikic/php-parser/bin/php-parse b/application/vendor/nikic/php-parser/bin/php-parse
new file mode 100644
index 0000000..974eb1a
--- /dev/null
+++ b/application/vendor/nikic/php-parser/bin/php-parse
@@ -0,0 +1,173 @@
+#!/usr/bin/env php
+ array(
+ 'startLine', 'endLine', 'startFilePos', 'endFilePos', 'comments'
+)));
+$parser = (new PhpParser\ParserFactory)->create(PhpParser\ParserFactory::PREFER_PHP7, $lexer);
+$dumper = new PhpParser\NodeDumper(['dumpComments' => true]);
+$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
+$serializer = new PhpParser\Serializer\XML;
+
+$traverser = new PhpParser\NodeTraverser();
+$traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver);
+
+foreach ($files as $file) {
+ if (strpos($file, ' Code $code\n";
+ } else {
+ if (!file_exists($file)) {
+ die("File $file does not exist.\n");
+ }
+
+ $code = file_get_contents($file);
+ echo "====> File $file:\n";
+ }
+
+ try {
+ $stmts = $parser->parse($code);
+ } catch (PhpParser\Error $e) {
+ if ($attributes['with-column-info'] && $e->hasColumnInfo()) {
+ $startLine = $e->getStartLine();
+ $endLine = $e->getEndLine();
+ $startColumn = $e->getStartColumn($code);
+ $endColumn = $e->getEndColumn($code);
+ $message .= $e->getRawMessage() . " from $startLine:$startColumn to $endLine:$endColumn";
+ } else {
+ $message = $e->getMessage();
+ }
+
+ die($message . "\n");
+ }
+
+ foreach ($operations as $operation) {
+ if ('dump' === $operation) {
+ echo "==> Node dump:\n";
+ echo $dumper->dump($stmts), "\n";
+ } elseif ('pretty-print' === $operation) {
+ echo "==> Pretty print:\n";
+ echo $prettyPrinter->prettyPrintFile($stmts), "\n";
+ } elseif ('serialize-xml' === $operation) {
+ echo "==> Serialized XML:\n";
+ echo $serializer->serialize($stmts), "\n";
+ } elseif ('var-dump' === $operation) {
+ echo "==> var_dump():\n";
+ var_dump($stmts);
+ } elseif ('resolve-names' === $operation) {
+ echo "==> Resolved names.\n";
+ $stmts = $traverser->traverse($stmts);
+ }
+ }
+}
+
+function showHelp($error = '') {
+ if ($error) {
+ echo $error . "\n\n";
+ }
+ die(<<