Completed
Push — output_formatting ( 5c6062...211baf )
by Emlyn
04:17 queued 01:36
created

Noop::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * @package    Fuel\Foundation
4
 * @version    2.0
5
 * @author     Fuel Development Team
6
 * @license    MIT License
7
 * @copyright  2010 - 2017 Fuel Development Team
8
 * @link       http://fuelphp.com
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fuel\Foundation\Formatter;
14
15
use Fuel\Foundation\Response\ResponseInterface;
16
use Zend\Diactoros\CallbackStream;
17
18
/**
19
 * Dummy formatter that simply passes the response right through.
20
 */
21
class Noop extends AbstractFormatter
22
{
23
24
	/**
25
	 * {@inheritdoc}
26
	 */
27 1
	public function canActivate($data) : bool
28
	{
29 1
		return true;
30
	}
31
32
	/**
33
	 * {@inheritdoc}
34
	 */
35 1
	public function format($data) : ResponseInterface
36
	{
37
		/** @var ResponseInterface $response */
38 1
		$response = $this->getContainer()->get('fuel.application.response');
39
40 1
		return $response->withBody(new CallbackStream(
41 1
			function() use ($data) {
42 1
				return $data;
43 1
			}
44
		));
45
	}
46
}
47