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 array_shift;
13
use function sprintf;
14
use PHPUnit\Framework\MockObject\Invocation;
15
use SebastianBergmann\Exporter\Exporter;
16
 
17
/**
18
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
19
 */
20
final class ConsecutiveCalls implements Stub
21
{
22
    /**
23
     * @var array
24
     */
25
    private $stack;
26
 
27
    /**
28
     * @var mixed
29
     */
30
    private $value;
31
 
32
    public function __construct(array $stack)
33
    {
34
        $this->stack = $stack;
35
    }
36
 
37
    public function invoke(Invocation $invocation)
38
    {
39
        $this->value = array_shift($this->stack);
40
 
41
        if ($this->value instanceof Stub) {
42
            $this->value = $this->value->invoke($invocation);
43
        }
44
 
45
        return $this->value;
46
    }
47
 
48
    public function toString(): string
49
    {
50
        $exporter = new Exporter;
51
 
52
        return sprintf(
53
            'return user-specified value %s',
54
            $exporter->export($this->value)
55
        );
56
    }
57
}