1<?php
2/*
3 * This file is part of the PHPUnit_MockObject package.
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
11/**
12 * Records invocations and provides convenience methods for checking them later
13 * on.
14 * This abstract class can be implemented by matchers which needs to check the
15 * number of times an invocation has occurred.
16 *
17 * @since Class available since Release 1.0.0
18 * @abstract
19 */
20abstract class PHPUnit_Framework_MockObject_Matcher_InvokedRecorder implements PHPUnit_Framework_MockObject_Matcher_Invocation
21{
22    /**
23     * @var PHPUnit_Framework_MockObject_Invocation[]
24     */
25    protected $invocations = [];
26
27    /**
28     * @return int
29     */
30    public function getInvocationCount()
31    {
32        return count($this->invocations);
33    }
34
35    /**
36     * @return PHPUnit_Framework_MockObject_Invocation[]
37     */
38    public function getInvocations()
39    {
40        return $this->invocations;
41    }
42
43    /**
44     * @return bool
45     */
46    public function hasBeenInvoked()
47    {
48        return count($this->invocations) > 0;
49    }
50
51    /**
52     * @param PHPUnit_Framework_MockObject_Invocation $invocation
53     */
54    public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation)
55    {
56        $this->invocations[] = $invocation;
57    }
58
59    /**
60     * @param PHPUnit_Framework_MockObject_Invocation $invocation
61     *
62     * @return bool
63     */
64    public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
65    {
66        return true;
67    }
68}
69