2f3fbadb1a6d8006f51aa8f4c0a410959a553725
[yaffs-website] / vendor / phpspec / prophecy / src / Prophecy / Call / Call.php
1 <?php
2
3 /*
4  * This file is part of the Prophecy.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *     Marcello Duarte <marcello.duarte@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Prophecy\Call;
13
14 use Exception;
15
16 /**
17  * Call object.
18  *
19  * @author Konstantin Kudryashov <ever.zet@gmail.com>
20  */
21 class Call
22 {
23     private $methodName;
24     private $arguments;
25     private $returnValue;
26     private $exception;
27     private $file;
28     private $line;
29
30     /**
31      * Initializes call.
32      *
33      * @param string      $methodName
34      * @param array       $arguments
35      * @param mixed       $returnValue
36      * @param Exception   $exception
37      * @param null|string $file
38      * @param null|int    $line
39      */
40     public function __construct($methodName, array $arguments, $returnValue,
41                                 Exception $exception = null, $file, $line)
42     {
43         $this->methodName  = $methodName;
44         $this->arguments   = $arguments;
45         $this->returnValue = $returnValue;
46         $this->exception   = $exception;
47
48         if ($file) {
49             $this->file = $file;
50             $this->line = intval($line);
51         }
52     }
53
54     /**
55      * Returns called method name.
56      *
57      * @return string
58      */
59     public function getMethodName()
60     {
61         return $this->methodName;
62     }
63
64     /**
65      * Returns called method arguments.
66      *
67      * @return array
68      */
69     public function getArguments()
70     {
71         return $this->arguments;
72     }
73
74     /**
75      * Returns called method return value.
76      *
77      * @return null|mixed
78      */
79     public function getReturnValue()
80     {
81         return $this->returnValue;
82     }
83
84     /**
85      * Returns exception that call thrown.
86      *
87      * @return null|Exception
88      */
89     public function getException()
90     {
91         return $this->exception;
92     }
93
94     /**
95      * Returns callee filename.
96      *
97      * @return string
98      */
99     public function getFile()
100     {
101         return $this->file;
102     }
103
104     /**
105      * Returns callee line number.
106      *
107      * @return int
108      */
109     public function getLine()
110     {
111         return $this->line;
112     }
113
114     /**
115      * Returns short notation for callee place.
116      *
117      * @return string
118      */
119     public function getCallPlace()
120     {
121         if (null === $this->file) {
122             return 'unknown';
123         }
124
125         return sprintf('%s:%d', $this->file, $this->line);
126     }
127 }