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 11use SebastianBergmann\Exporter\Exporter; 12 13/** 14 * Stubs a method by returning a user-defined value. 15 * 16 * @since Class available since Release 1.0.0 17 */ 18class PHPUnit_Framework_MockObject_Stub_Return implements PHPUnit_Framework_MockObject_Stub 19{ 20 protected $value; 21 22 public function __construct($value) 23 { 24 $this->value = $value; 25 } 26 27 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) 28 { 29 return $this->value; 30 } 31 32 public function toString() 33 { 34 $exporter = new Exporter; 35 36 return sprintf( 37 'return user-specified value %s', 38 $exporter->export($this->value) 39 ); 40 } 41} 42