diff --git a/source/Mocka/FunctionMock.php b/source/Mocka/FunctionMock.php index 2ca7bbf..3a309a9 100644 --- a/source/Mocka/FunctionMock.php +++ b/source/Mocka/FunctionMock.php @@ -82,6 +82,13 @@ public function getCall($number) { return $this->getCalls()->get($number); } + /** + * @return Invocation + */ + public function getLastCall() { + return $this->getInvocations()->getLast(); + } + /** * @return int */ diff --git a/source/Mocka/Invocations.php b/source/Mocka/Invocations.php index b44fd0c..10fdc56 100644 --- a/source/Mocka/Invocations.php +++ b/source/Mocka/Invocations.php @@ -7,6 +7,10 @@ class Invocations { /** @var Invocation[] */ private $_list; + public function __construct() { + $this->_list = []; + } + /** * @param Invocation $invocation */ @@ -26,6 +30,15 @@ public function get($number) { return $this->_list[$number]; } + /** + * @return Invocation + * @throws Exception + */ + public function getLast() { + $last = $this->getCount() - 1; + return $this->get($last); + } + /** * @return int */