CoreFiles by mySites.guru
LazyAssertionException.php55 lines, 1,291 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
cb5c50f7d68f0707e09aae1162106db3
sha1
c93c0b3318c43001bf8bce6195f7f6a370ed24f6
sha256
2d376fbaf70eb0703b2c561dc9ba272bae3e61866b800399ebd827e7fe134de1
<?php

/**
 * Assert
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file LICENSE.txt.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so I can send you a copy immediately.
 */

namespace Assert;

class LazyAssertionException extends InvalidArgumentException
{
    /**
     * @var InvalidArgumentException[]
     */
    private $errors = [];

    /**
     * @param InvalidArgumentException[] $errors
     *
     * @return self
     */
    public static function fromErrors(array $errors): self
    {
        $message = \sprintf('The following %d assertions failed:', \count($errors))."\n";

        $i = 1;
        foreach ($errors as $error) {
            $message .= \sprintf("%d) %s: %s\n", $i++, $error->getPropertyPath(), $error->getMessage());
        }

        return new static($message, $errors);
    }

    public function __construct($message, array $errors)
    {
        parent::__construct($message, 0, null, null);

        $this->errors = $errors;
    }

    /**
     * @return InvalidArgumentException[]
     */
    public function getErrorExceptions(): array
    {
        return $this->errors;
    }
}

The same content is in 7 releases, Joomla 4.0.0-beta to 4.0.0-beta7. See them all, or every version of this file.