Skip to content

Commit

Permalink
Merge pull request #36 from tomaszdurka/issue-36
Browse files Browse the repository at this point in the history
Add getLastCall()
  • Loading branch information
tomaszdurka committed Apr 18, 2016
2 parents b8210f7 + 5d6f2c3 commit 2c242b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/Mocka/FunctionMock.php
Expand Up @@ -82,6 +82,13 @@ public function getCall($number) {
return $this->getCalls()->get($number);
}

/**
* @return Invocation
*/
public function getLastCall() {
return $this->getInvocations()->getLast();
}

/**
* @return int
*/
Expand Down
13 changes: 13 additions & 0 deletions source/Mocka/Invocations.php
Expand Up @@ -7,6 +7,10 @@ class Invocations {
/** @var Invocation[] */
private $_list;

public function __construct() {
$this->_list = [];
}

/**
* @param Invocation $invocation
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 2c242b2

Please sign in to comment.