@@ -17,51 +17,51 @@ |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - if( !interface_exists( '\Psr\Http\Message\ServerRequestInterface' ) ) { |
|
21 | - $this->markTestSkipped( '\Psr\Http\Message\ServerRequestInterface is not available' ); |
|
20 | + if (!interface_exists('\Psr\Http\Message\ServerRequestInterface')) { |
|
21 | + $this->markTestSkipped('\Psr\Http\Message\ServerRequestInterface is not available'); |
|
22 | 22 | } |
23 | 23 | |
24 | - if( !class_exists( '\Slim\Route' ) ) { |
|
25 | - $this->markTestSkipped( '\Slim\Route is not available' ); |
|
24 | + if (!class_exists('\Slim\Route')) { |
|
25 | + $this->markTestSkipped('\Slim\Route is not available'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $view = new \Aimeos\MW\View\Standard(); |
29 | - $route = new \Slim\Route( array( 'GET' ), '/shop', null ); |
|
30 | - $route->setName( 'route' ); |
|
29 | + $route = new \Slim\Route(array('GET'), '/shop', null); |
|
30 | + $route->setName('route'); |
|
31 | 31 | |
32 | - $this->mock = $this->getMock( '\Psr\Http\Message\ServerRequestInterface' ); |
|
32 | + $this->mock = $this->getMock('\Psr\Http\Message\ServerRequestInterface'); |
|
33 | 33 | |
34 | - $this->mock->expects( $this->once() )->method( 'getAttribute' ) |
|
35 | - ->will( $this->returnValue( $route ) ); |
|
34 | + $this->mock->expects($this->once())->method('getAttribute') |
|
35 | + ->will($this->returnValue($route)); |
|
36 | 36 | |
37 | - $this->mock->expects( $this->once() )->method( 'getServerParams' ) |
|
38 | - ->will( $this->returnValue( array( 'REMOTE_ADDR' => '127.0.0.1' ) ) ); |
|
37 | + $this->mock->expects($this->once())->method('getServerParams') |
|
38 | + ->will($this->returnValue(array('REMOTE_ADDR' => '127.0.0.1'))); |
|
39 | 39 | |
40 | - $this->object = new \Aimeos\MW\View\Helper\Request\Slim( $view, $this->mock ); |
|
40 | + $this->object = new \Aimeos\MW\View\Helper\Request\Slim($view, $this->mock); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | protected function tearDown() |
45 | 45 | { |
46 | - unset( $this->object, $this->mock ); |
|
46 | + unset($this->object, $this->mock); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testTransform() |
51 | 51 | { |
52 | - $this->assertInstanceOf( '\Aimeos\MW\View\Helper\Request\Slim', $this->object->transform() ); |
|
53 | - $this->assertInstanceOf( '\Psr\Http\Message\ServerRequestInterface', $this->object->transform() ); |
|
52 | + $this->assertInstanceOf('\Aimeos\MW\View\Helper\Request\Slim', $this->object->transform()); |
|
53 | + $this->assertInstanceOf('\Psr\Http\Message\ServerRequestInterface', $this->object->transform()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testGetClientAddress() |
58 | 58 | { |
59 | - $this->assertEquals( '127.0.0.1', $this->object->getClientAddress() ); |
|
59 | + $this->assertEquals('127.0.0.1', $this->object->getClientAddress()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | 63 | public function testGetTarget() |
64 | 64 | { |
65 | - $this->assertEquals( 'route', $this->object->getTarget() ); |
|
65 | + $this->assertEquals('route', $this->object->getTarget()); |
|
66 | 66 | } |
67 | 67 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @param \Aimeos\MW\View\Iface $view View instance with registered view helpers |
28 | 28 | * @param \Psr\Http\Message\ServerRequestInterface $request PSR-7 request object |
29 | 29 | */ |
30 | - public function __construct( \Aimeos\MW\View\Iface $view, \Psr\Http\Message\ServerRequestInterface $request ) |
|
30 | + public function __construct(\Aimeos\MW\View\Iface $view, \Psr\Http\Message\ServerRequestInterface $request) |
|
31 | 31 | { |
32 | - $route = $request->getAttribute( 'route' ); |
|
32 | + $route = $request->getAttribute('route'); |
|
33 | 33 | |
34 | - parent::__construct( $view, $request, $this->getIPAddress( $request ), ( $route ? $route->getName() : null ) ); |
|
34 | + parent::__construct($view, $request, $this->getIPAddress($request), ($route ? $route->getName() : null)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | * @param \Psr\Http\Message\ServerRequestInterface $request |
42 | 42 | * @return string|null IPv4 or IPv6 address or null if invalid |
43 | 43 | */ |
44 | - protected function getIPAddress( \Psr\Http\Message\ServerRequestInterface $request ) |
|
44 | + protected function getIPAddress(\Psr\Http\Message\ServerRequestInterface $request) |
|
45 | 45 | { |
46 | 46 | $server = $request->getServerParams(); |
47 | 47 | $flags = FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6; |
48 | 48 | |
49 | - if( isset( $server['REMOTE_ADDR'] ) |
|
50 | - && ( $ip = filter_var( $server['REMOTE_ADDR'], FILTER_VALIDATE_IP, $flags ) ) !== false |
|
49 | + if (isset($server['REMOTE_ADDR']) |
|
50 | + && ($ip = filter_var($server['REMOTE_ADDR'], FILTER_VALIDATE_IP, $flags)) !== false |
|
51 | 51 | ) { |
52 | 52 | return $ip; |
53 | 53 | } |