Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Framework\MockObject\Stub;
11
 
12
use function sprintf;
13
use PHPUnit\Framework\MockObject\Invocation;
14
use SebastianBergmann\Exporter\Exporter;
15
use Throwable;
16
 
17
/**
18
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
19
 */
20
final class Exception implements Stub
21
{
22
    private $exception;
23
 
24
    public function __construct(Throwable $exception)
25
    {
26
        $this->exception = $exception;
27
    }
28
 
29
    /**
30
     * @throws Throwable
31
     */
32
    public function invoke(Invocation $invocation): void
33
    {
34
        throw $this->exception;
35
    }
36
 
37
    public function toString(): string
38
    {
39
        $exporter = new Exporter;
40
 
41
        return sprintf(
42
            'raise user-specified exception %s',
43
            $exporter->export($this->exception)
44
        );
45
    }
46
}