Passed
Branch 2.0 (d24509)
by Donald
02:04
created

UnMockedResponseExceptionAnswer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 21
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processAnswer() 0 2 1
A getAnswerCallback() 0 7 1
1
<?php namespace Chekote\Phake\Stubber\Answers;
2
3
use Chekote\Phake\Exception\UnMockedResponseException;
4
use Phake_Stubber_IAnswer;
5
6
/**
7
 * Throws an Exception stating the class and method name that was called.
8
 */
9
class UnMockedResponseExceptionAnswer implements Phake_Stubber_IAnswer
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function getAnswerCallback($context, $method)
15
    {
16
        $class = get_parent_class($context);
17
18
        return function () use ($class, $method) {
19
            throw new UnMockedResponseException(
20
                "$class::$method was called on mock without having its response mocked"
21
            );
22
        };
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function processAnswer($answer)
29
    {
30
    }
31
}
32