@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | public function testAddOneHostThenGetConnection() |
| 26 | 26 | { |
| 27 | 27 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 28 | - ->shouldReceive('ping') |
|
| 29 | - ->andReturn(true) |
|
| 30 | - ->getMock() |
|
| 31 | - ->shouldReceive('isAlive') |
|
| 32 | - ->andReturn(true) |
|
| 33 | - ->getMock() |
|
| 34 | - ->shouldReceive('markDead')->once()->getMock(); |
|
| 28 | + ->shouldReceive('ping') |
|
| 29 | + ->andReturn(true) |
|
| 30 | + ->getMock() |
|
| 31 | + ->shouldReceive('isAlive') |
|
| 32 | + ->andReturn(true) |
|
| 33 | + ->getMock() |
|
| 34 | + ->shouldReceive('markDead')->once()->getMock(); |
|
| 35 | 35 | |
| 36 | 36 | $connections = array($mockConnection); |
| 37 | 37 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | foreach (range(1,10) as $index) { |
| 61 | 61 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 62 | - ->shouldReceive('ping') |
|
| 63 | - ->andReturn(true) |
|
| 64 | - ->getMock() |
|
| 65 | - ->shouldReceive('isAlive') |
|
| 66 | - ->andReturn(true) |
|
| 67 | - ->getMock() |
|
| 68 | - ->shouldReceive('markDead')->once()->getMock(); |
|
| 62 | + ->shouldReceive('ping') |
|
| 63 | + ->andReturn(true) |
|
| 64 | + ->getMock() |
|
| 65 | + ->shouldReceive('isAlive') |
|
| 66 | + ->andReturn(true) |
|
| 67 | + ->getMock() |
|
| 68 | + ->shouldReceive('markDead')->once()->getMock(); |
|
| 69 | 69 | |
| 70 | 70 | $connections[] = $mockConnection; |
| 71 | 71 | } |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | foreach (range(1,10) as $index) { |
| 98 | 98 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 99 | - ->shouldReceive('ping') |
|
| 100 | - ->andReturn(false) |
|
| 101 | - ->getMock() |
|
| 102 | - ->shouldReceive('isAlive') |
|
| 103 | - ->andReturn(false) |
|
| 104 | - ->getMock() |
|
| 105 | - ->shouldReceive('markDead')->once()->getMock() |
|
| 106 | - ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 107 | - ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 99 | + ->shouldReceive('ping') |
|
| 100 | + ->andReturn(false) |
|
| 101 | + ->getMock() |
|
| 102 | + ->shouldReceive('isAlive') |
|
| 103 | + ->andReturn(false) |
|
| 104 | + ->getMock() |
|
| 105 | + ->shouldReceive('markDead')->once()->getMock() |
|
| 106 | + ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 107 | + ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 108 | 108 | |
| 109 | 109 | $connections[] = $mockConnection; |
| 110 | 110 | } |
@@ -131,29 +131,29 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | foreach (range(1,9) as $index) { |
| 133 | 133 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 134 | - ->shouldReceive('ping') |
|
| 135 | - ->andReturn(false) |
|
| 136 | - ->getMock() |
|
| 137 | - ->shouldReceive('isAlive') |
|
| 138 | - ->andReturn(false) |
|
| 139 | - ->getMock() |
|
| 140 | - ->shouldReceive('markDead')->once()->getMock() |
|
| 141 | - ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 142 | - ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 134 | + ->shouldReceive('ping') |
|
| 135 | + ->andReturn(false) |
|
| 136 | + ->getMock() |
|
| 137 | + ->shouldReceive('isAlive') |
|
| 138 | + ->andReturn(false) |
|
| 139 | + ->getMock() |
|
| 140 | + ->shouldReceive('markDead')->once()->getMock() |
|
| 141 | + ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 142 | + ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 143 | 143 | |
| 144 | 144 | $connections[] = $mockConnection; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $goodConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 148 | - ->shouldReceive('ping')->once() |
|
| 149 | - ->andReturn(true) |
|
| 150 | - ->getMock() |
|
| 151 | - ->shouldReceive('isAlive')->once() |
|
| 152 | - ->andReturn(false) |
|
| 153 | - ->getMock() |
|
| 154 | - ->shouldReceive('markDead')->once()->getMock() |
|
| 155 | - ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 156 | - ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 148 | + ->shouldReceive('ping')->once() |
|
| 149 | + ->andReturn(true) |
|
| 150 | + ->getMock() |
|
| 151 | + ->shouldReceive('isAlive')->once() |
|
| 152 | + ->andReturn(false) |
|
| 153 | + ->getMock() |
|
| 154 | + ->shouldReceive('markDead')->once()->getMock() |
|
| 155 | + ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 156 | + ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 157 | 157 | |
| 158 | 158 | $connections[] = $goodConnection; |
| 159 | 159 | |
@@ -179,29 +179,29 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | foreach (range(1,9) as $index) { |
| 181 | 181 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 182 | - ->shouldReceive('ping') |
|
| 183 | - ->andReturn(false) |
|
| 184 | - ->getMock() |
|
| 185 | - ->shouldReceive('isAlive') |
|
| 186 | - ->andReturn(false) |
|
| 187 | - ->getMock() |
|
| 188 | - ->shouldReceive('markDead')->once()->getMock() |
|
| 189 | - ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 190 | - ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 182 | + ->shouldReceive('ping') |
|
| 183 | + ->andReturn(false) |
|
| 184 | + ->getMock() |
|
| 185 | + ->shouldReceive('isAlive') |
|
| 186 | + ->andReturn(false) |
|
| 187 | + ->getMock() |
|
| 188 | + ->shouldReceive('markDead')->once()->getMock() |
|
| 189 | + ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 190 | + ->shouldReceive('getLastPing')->andReturn(time())->once()->getMock(); |
|
| 191 | 191 | |
| 192 | 192 | $connections[] = $mockConnection; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $goodConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 196 | - ->shouldReceive('ping')->once() |
|
| 197 | - ->andReturn(true) |
|
| 198 | - ->getMock() |
|
| 199 | - ->shouldReceive('isAlive')->once() |
|
| 200 | - ->andReturn(false) |
|
| 201 | - ->getMock() |
|
| 202 | - ->shouldReceive('markDead')->once()->getMock() |
|
| 203 | - ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 204 | - ->shouldReceive('getLastPing')->andReturn(time()-10000)->once()->getMock(); |
|
| 196 | + ->shouldReceive('ping')->once() |
|
| 197 | + ->andReturn(true) |
|
| 198 | + ->getMock() |
|
| 199 | + ->shouldReceive('isAlive')->once() |
|
| 200 | + ->andReturn(false) |
|
| 201 | + ->getMock() |
|
| 202 | + ->shouldReceive('markDead')->once()->getMock() |
|
| 203 | + ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
|
| 204 | + ->shouldReceive('getLastPing')->andReturn(time()-10000)->once()->getMock(); |
|
| 205 | 205 | |
| 206 | 206 | $connections[] = $goodConnection; |
| 207 | 207 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | ->getMock() |
| 34 | 34 | ->shouldReceive('markDead')->once()->getMock(); |
| 35 | 35 | |
| 36 | - $connections = array($mockConnection); |
|
| 36 | + $connections = array ($mockConnection); |
|
| 37 | 37 | |
| 38 | 38 | $selector = m::mock('\Elasticsearch\ConnectionPool\Selectors\RoundRobinSelector') |
| 39 | 39 | ->shouldReceive('select') |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | public function testAddMultipleHostsThenGetFirst() |
| 56 | 56 | { |
| 57 | 57 | |
| 58 | - $connections = array(); |
|
| 58 | + $connections = array (); |
|
| 59 | 59 | |
| 60 | - foreach (range(1,10) as $index) { |
|
| 60 | + foreach (range(1, 10) as $index) { |
|
| 61 | 61 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 62 | 62 | ->shouldReceive('ping') |
| 63 | 63 | ->andReturn(true) |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | public function testAllHostsFailPing() |
| 93 | 93 | { |
| 94 | 94 | |
| 95 | - $connections = array(); |
|
| 95 | + $connections = array (); |
|
| 96 | 96 | |
| 97 | - foreach (range(1,10) as $index) { |
|
| 97 | + foreach (range(1, 10) as $index) { |
|
| 98 | 98 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 99 | 99 | ->shouldReceive('ping') |
| 100 | 100 | ->andReturn(false) |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | public function testAllExceptLastHostFailPingRevivesInSkip() |
| 128 | 128 | { |
| 129 | 129 | |
| 130 | - $connections = array(); |
|
| 130 | + $connections = array (); |
|
| 131 | 131 | |
| 132 | - foreach (range(1,9) as $index) { |
|
| 132 | + foreach (range(1, 9) as $index) { |
|
| 133 | 133 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 134 | 134 | ->shouldReceive('ping') |
| 135 | 135 | ->andReturn(false) |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | public function testAllExceptLastHostFailPingRevivesPreSkip() |
| 176 | 176 | { |
| 177 | 177 | |
| 178 | - $connections = array(); |
|
| 178 | + $connections = array (); |
|
| 179 | 179 | |
| 180 | - foreach (range(1,9) as $index) { |
|
| 180 | + foreach (range(1, 9) as $index) { |
|
| 181 | 181 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 182 | 182 | ->shouldReceive('ping') |
| 183 | 183 | ->andReturn(false) |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | ->getMock() |
| 202 | 202 | ->shouldReceive('markDead')->once()->getMock() |
| 203 | 203 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
| 204 | - ->shouldReceive('getLastPing')->andReturn(time()-10000)->once()->getMock(); |
|
| 204 | + ->shouldReceive('getLastPing')->andReturn(time() - 10000)->once()->getMock(); |
|
| 205 | 205 | |
| 206 | 206 | $connections[] = $goodConnection; |
| 207 | 207 | |
@@ -15,15 +15,13 @@ discard block |
||
| 15 | 15 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 |
| 16 | 16 | * @link http://elasticsearch.org |
| 17 | 17 | */ |
| 18 | -class StaticConnectionPoolTest extends \PHPUnit_Framework_TestCase |
|
| 19 | -{ |
|
| 18 | +class StaticConnectionPoolTest extends \PHPUnit_Framework_TestCase { |
|
| 20 | 19 | |
| 21 | 20 | public function tearDown() { |
| 22 | 21 | m::close(); |
| 23 | 22 | } |
| 24 | 23 | |
| 25 | - public function testAddOneHostThenGetConnection() |
|
| 26 | - { |
|
| 24 | + public function testAddOneHostThenGetConnection() { |
|
| 27 | 25 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 28 | 26 | ->shouldReceive('ping') |
| 29 | 27 | ->andReturn(true) |
@@ -52,8 +50,7 @@ discard block |
||
| 52 | 50 | } |
| 53 | 51 | |
| 54 | 52 | |
| 55 | - public function testAddMultipleHostsThenGetFirst() |
|
| 56 | - { |
|
| 53 | + public function testAddMultipleHostsThenGetFirst() { |
|
| 57 | 54 | |
| 58 | 55 | $connections = array(); |
| 59 | 56 | |
@@ -89,8 +86,7 @@ discard block |
||
| 89 | 86 | /** |
| 90 | 87 | * @expectedException Elasticsearch\Common\Exceptions\NoNodesAvailableException |
| 91 | 88 | */ |
| 92 | - public function testAllHostsFailPing() |
|
| 93 | - { |
|
| 89 | + public function testAllHostsFailPing() { |
|
| 94 | 90 | |
| 95 | 91 | $connections = array(); |
| 96 | 92 | |
@@ -124,8 +120,7 @@ discard block |
||
| 124 | 120 | } |
| 125 | 121 | |
| 126 | 122 | |
| 127 | - public function testAllExceptLastHostFailPingRevivesInSkip() |
|
| 128 | - { |
|
| 123 | + public function testAllExceptLastHostFailPingRevivesInSkip() { |
|
| 129 | 124 | |
| 130 | 125 | $connections = array(); |
| 131 | 126 | |
@@ -172,8 +167,7 @@ discard block |
||
| 172 | 167 | |
| 173 | 168 | } |
| 174 | 169 | |
| 175 | - public function testAllExceptLastHostFailPingRevivesPreSkip() |
|
| 176 | - { |
|
| 170 | + public function testAllExceptLastHostFailPingRevivesPreSkip() { |
|
| 177 | 171 | |
| 178 | 172 | $connections = array(); |
| 179 | 173 | |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 28 | 28 | ->shouldReceive('ping') |
| 29 | - ->andReturn(true) |
|
| 29 | + ->andReturn(TRUE) |
|
| 30 | 30 | ->getMock() |
| 31 | 31 | ->shouldReceive('isAlive') |
| 32 | - ->andReturn(true) |
|
| 32 | + ->andReturn(TRUE) |
|
| 33 | 33 | ->getMock() |
| 34 | 34 | ->shouldReceive('markDead')->once()->getMock(); |
| 35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $connectionFactory = m::mock('\Elasticsearch\Connections\ConnectionFactory'); |
| 44 | 44 | |
| 45 | - $randomizeHosts = false; |
|
| 45 | + $randomizeHosts = FALSE; |
|
| 46 | 46 | $connectionPool = new \Elasticsearch\ConnectionPool\StaticConnectionPool($connections, $selector, $connectionFactory, $randomizeHosts); |
| 47 | 47 | |
| 48 | 48 | $retConnection = $connectionPool->nextConnection(); |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | foreach (range(1,10) as $index) { |
| 61 | 61 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 62 | 62 | ->shouldReceive('ping') |
| 63 | - ->andReturn(true) |
|
| 63 | + ->andReturn(TRUE) |
|
| 64 | 64 | ->getMock() |
| 65 | 65 | ->shouldReceive('isAlive') |
| 66 | - ->andReturn(true) |
|
| 66 | + ->andReturn(TRUE) |
|
| 67 | 67 | ->getMock() |
| 68 | 68 | ->shouldReceive('markDead')->once()->getMock(); |
| 69 | 69 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $connectionFactory = m::mock('\Elasticsearch\Connections\ConnectionFactory'); |
| 79 | 79 | |
| 80 | - $randomizeHosts = false; |
|
| 80 | + $randomizeHosts = FALSE; |
|
| 81 | 81 | $connectionPool = new \Elasticsearch\ConnectionPool\StaticConnectionPool($connections, $selector, $connectionFactory, $randomizeHosts); |
| 82 | 82 | |
| 83 | 83 | $retConnection = $connectionPool->nextConnection(); |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | foreach (range(1,10) as $index) { |
| 98 | 98 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 99 | 99 | ->shouldReceive('ping') |
| 100 | - ->andReturn(false) |
|
| 100 | + ->andReturn(FALSE) |
|
| 101 | 101 | ->getMock() |
| 102 | 102 | ->shouldReceive('isAlive') |
| 103 | - ->andReturn(false) |
|
| 103 | + ->andReturn(FALSE) |
|
| 104 | 104 | ->getMock() |
| 105 | 105 | ->shouldReceive('markDead')->once()->getMock() |
| 106 | 106 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $connectionFactory = m::mock('\Elasticsearch\Connections\ConnectionFactory'); |
| 118 | 118 | |
| 119 | - $randomizeHosts = false; |
|
| 119 | + $randomizeHosts = FALSE; |
|
| 120 | 120 | $connectionPool = new \Elasticsearch\ConnectionPool\StaticConnectionPool($connections, $selector, $connectionFactory, $randomizeHosts); |
| 121 | 121 | |
| 122 | 122 | $connectionPool->nextConnection(); |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | foreach (range(1,9) as $index) { |
| 133 | 133 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 134 | 134 | ->shouldReceive('ping') |
| 135 | - ->andReturn(false) |
|
| 135 | + ->andReturn(FALSE) |
|
| 136 | 136 | ->getMock() |
| 137 | 137 | ->shouldReceive('isAlive') |
| 138 | - ->andReturn(false) |
|
| 138 | + ->andReturn(FALSE) |
|
| 139 | 139 | ->getMock() |
| 140 | 140 | ->shouldReceive('markDead')->once()->getMock() |
| 141 | 141 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $goodConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 148 | 148 | ->shouldReceive('ping')->once() |
| 149 | - ->andReturn(true) |
|
| 149 | + ->andReturn(TRUE) |
|
| 150 | 150 | ->getMock() |
| 151 | 151 | ->shouldReceive('isAlive')->once() |
| 152 | - ->andReturn(false) |
|
| 152 | + ->andReturn(FALSE) |
|
| 153 | 153 | ->getMock() |
| 154 | 154 | ->shouldReceive('markDead')->once()->getMock() |
| 155 | 155 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $connectionFactory = m::mock('\Elasticsearch\Connections\ConnectionFactory'); |
| 166 | 166 | |
| 167 | - $randomizeHosts = false; |
|
| 167 | + $randomizeHosts = FALSE; |
|
| 168 | 168 | $connectionPool = new \Elasticsearch\ConnectionPool\StaticConnectionPool($connections, $selector, $connectionFactory, $randomizeHosts); |
| 169 | 169 | |
| 170 | 170 | $ret = $connectionPool->nextConnection(); |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | foreach (range(1,9) as $index) { |
| 181 | 181 | $mockConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 182 | 182 | ->shouldReceive('ping') |
| 183 | - ->andReturn(false) |
|
| 183 | + ->andReturn(FALSE) |
|
| 184 | 184 | ->getMock() |
| 185 | 185 | ->shouldReceive('isAlive') |
| 186 | - ->andReturn(false) |
|
| 186 | + ->andReturn(FALSE) |
|
| 187 | 187 | ->getMock() |
| 188 | 188 | ->shouldReceive('markDead')->once()->getMock() |
| 189 | 189 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $goodConnection = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 196 | 196 | ->shouldReceive('ping')->once() |
| 197 | - ->andReturn(true) |
|
| 197 | + ->andReturn(TRUE) |
|
| 198 | 198 | ->getMock() |
| 199 | 199 | ->shouldReceive('isAlive')->once() |
| 200 | - ->andReturn(false) |
|
| 200 | + ->andReturn(FALSE) |
|
| 201 | 201 | ->getMock() |
| 202 | 202 | ->shouldReceive('markDead')->once()->getMock() |
| 203 | 203 | ->shouldReceive('getPingFailures')->andReturn(0)->once()->getMock() |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $connectionFactory = m::mock('\Elasticsearch\Connections\ConnectionFactory'); |
| 214 | 214 | |
| 215 | - $randomizeHosts = false; |
|
| 215 | + $randomizeHosts = FALSE; |
|
| 216 | 216 | $connectionPool = new \Elasticsearch\ConnectionPool\StaticConnectionPool($connections, $selector, $connectionFactory, $randomizeHosts); |
| 217 | 217 | |
| 218 | 218 | $ret = $connectionPool->nextConnection(); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $mockConnections = array(); |
| 35 | 35 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 36 | - ->shouldReceive('isAlive')->times(16)->andReturn(true)->getMock(); |
|
| 36 | + ->shouldReceive('isAlive')->times(16)->andReturn(true)->getMock(); |
|
| 37 | 37 | |
| 38 | 38 | foreach (range(0,9) as $index) { |
| 39 | 39 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $mockConnections = array(); |
| 56 | 56 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 57 | - ->shouldReceive('isAlive')->once()->andReturn(false)->getMock(); |
|
| 57 | + ->shouldReceive('isAlive')->once()->andReturn(false)->getMock(); |
|
| 58 | 58 | |
| 59 | 59 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 60 | - ->shouldReceive('isAlive')->times(15)->andReturn(true)->getMock(); |
|
| 60 | + ->shouldReceive('isAlive')->times(15)->andReturn(true)->getMock(); |
|
| 61 | 61 | |
| 62 | 62 | foreach (range(0,8) as $index) { |
| 63 | 63 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
@@ -31,16 +31,16 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector(); |
| 33 | 33 | |
| 34 | - $mockConnections = array(); |
|
| 34 | + $mockConnections = array (); |
|
| 35 | 35 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 36 | 36 | ->shouldReceive('isAlive')->times(16)->andReturn(true)->getMock(); |
| 37 | 37 | |
| 38 | - foreach (range(0,9) as $index) { |
|
| 38 | + foreach (range(0, 9) as $index) { |
|
| 39 | 39 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
| 43 | - foreach (range(0,15) as $index) { |
|
| 43 | + foreach (range(0, 15) as $index) { |
|
| 44 | 44 | $retConnection = $roundRobin->select($mockConnections); |
| 45 | 45 | |
| 46 | 46 | $this->assertEquals($mockConnections[0], $retConnection); |
@@ -52,19 +52,19 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector(); |
| 54 | 54 | |
| 55 | - $mockConnections = array(); |
|
| 55 | + $mockConnections = array (); |
|
| 56 | 56 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 57 | 57 | ->shouldReceive('isAlive')->once()->andReturn(false)->getMock(); |
| 58 | 58 | |
| 59 | 59 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 60 | 60 | ->shouldReceive('isAlive')->times(15)->andReturn(true)->getMock(); |
| 61 | 61 | |
| 62 | - foreach (range(0,8) as $index) { |
|
| 62 | + foreach (range(0, 8) as $index) { |
|
| 63 | 63 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - foreach (range(0,15) as $index) { |
|
| 67 | + foreach (range(0, 15) as $index) { |
|
| 68 | 68 | $retConnection = $roundRobin->select($mockConnections); |
| 69 | 69 | |
| 70 | 70 | $this->assertEquals($mockConnections[1], $retConnection); |
@@ -19,16 +19,14 @@ discard block |
||
| 19 | 19 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 |
| 20 | 20 | * @link http://elasticsearch.org |
| 21 | 21 | */ |
| 22 | -class StickyRoundRobinSelectorTest extends \PHPUnit_Framework_TestCase |
|
| 23 | -{ |
|
| 22 | +class StickyRoundRobinSelectorTest extends \PHPUnit_Framework_TestCase { |
|
| 24 | 23 | |
| 25 | 24 | public function tearDown() { |
| 26 | 25 | m::close(); |
| 27 | 26 | } |
| 28 | 27 | |
| 29 | 28 | |
| 30 | - public function testTenConnections() |
|
| 31 | - { |
|
| 29 | + public function testTenConnections() { |
|
| 32 | 30 | $roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector(); |
| 33 | 31 | |
| 34 | 32 | $mockConnections = array(); |
@@ -48,8 +46,7 @@ discard block |
||
| 48 | 46 | |
| 49 | 47 | } |
| 50 | 48 | |
| 51 | - public function testTenConnectionsFirstDies() |
|
| 52 | - { |
|
| 49 | + public function testTenConnectionsFirstDies() { |
|
| 53 | 50 | $roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector(); |
| 54 | 51 | |
| 55 | 52 | $mockConnections = array(); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $mockConnections = array(); |
| 35 | 35 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 36 | - ->shouldReceive('isAlive')->times(16)->andReturn(true)->getMock(); |
|
| 36 | + ->shouldReceive('isAlive')->times(16)->andReturn(TRUE)->getMock(); |
|
| 37 | 37 | |
| 38 | 38 | foreach (range(0,9) as $index) { |
| 39 | 39 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $mockConnections = array(); |
| 56 | 56 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 57 | - ->shouldReceive('isAlive')->once()->andReturn(false)->getMock(); |
|
| 57 | + ->shouldReceive('isAlive')->once()->andReturn(FALSE)->getMock(); |
|
| 58 | 58 | |
| 59 | 59 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection') |
| 60 | - ->shouldReceive('isAlive')->times(15)->andReturn(true)->getMock(); |
|
| 60 | + ->shouldReceive('isAlive')->times(15)->andReturn(TRUE)->getMock(); |
|
| 61 | 61 | |
| 62 | 62 | foreach (range(0,8) as $index) { |
| 63 | 63 | $mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection'); |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | |
| 13 | 13 | public $body, |
| 14 | - $raw_body, |
|
| 15 | - $headers, |
|
| 16 | - $raw_headers, |
|
| 17 | - $request, |
|
| 18 | - $code = 0, |
|
| 19 | - $content_type, |
|
| 20 | - $parent_type, |
|
| 21 | - $charset, |
|
| 22 | - $meta_data, |
|
| 23 | - $is_mime_vendor_specific = false, |
|
| 24 | - $is_mime_personal = false; |
|
| 14 | + $raw_body, |
|
| 15 | + $headers, |
|
| 16 | + $raw_headers, |
|
| 17 | + $request, |
|
| 18 | + $code = 0, |
|
| 19 | + $content_type, |
|
| 20 | + $parent_type, |
|
| 21 | + $charset, |
|
| 22 | + $meta_data, |
|
| 23 | + $is_mime_vendor_specific = false, |
|
| 24 | + $is_mime_personal = false; |
|
| 25 | 25 | |
| 26 | 26 | private $parsers; |
| 27 | 27 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | : $this->parent_type; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - return Httpful::get($parse_with)->parse($body); |
|
| 106 | + return Httpful::get($parse_with)->parse($body); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param Request $request |
| 31 | 31 | * @param array $meta_data |
| 32 | 32 | */ |
| 33 | - public function __construct($body, $headers, Request $request, array $meta_data = array()) |
|
| 33 | + public function __construct($body, $headers, Request $request, array $meta_data = array ()) |
|
| 34 | 34 | { |
| 35 | 35 | $this->request = $request; |
| 36 | 36 | $this->raw_headers = $headers; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->_interpretHeaders(); |
| 44 | 44 | |
| 45 | - $this->body = $this->_parse($body); |
|
| 45 | + $this->body = $this->_parse($body); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | public function _parseHeaders($headers) |
| 116 | 116 | { |
| 117 | 117 | $headers = preg_split("/(\r|\n)+/", $headers, -1, \PREG_SPLIT_NO_EMPTY); |
| 118 | - $parse_headers = array(); |
|
| 118 | + $parse_headers = array (); |
|
| 119 | 119 | for ($i = 1; $i < count($headers); $i++) { |
| 120 | 120 | list($key, $raw_value) = explode(':', $headers[$i], 2); |
| 121 | 121 | $key = trim($key); |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | * @author Nate Good <[email protected]> |
| 9 | 9 | */ |
| 10 | -class Response |
|
| 11 | -{ |
|
| 10 | +class Response { |
|
| 12 | 11 | |
| 13 | 12 | public $body, |
| 14 | 13 | $raw_body, |
@@ -30,8 +29,7 @@ discard block |
||
| 30 | 29 | * @param Request $request |
| 31 | 30 | * @param array $meta_data |
| 32 | 31 | */ |
| 33 | - public function __construct($body, $headers, Request $request, array $meta_data = array()) |
|
| 34 | - { |
|
| 32 | + public function __construct($body, $headers, Request $request, array $meta_data = array()) { |
|
| 35 | 33 | $this->request = $request; |
| 36 | 34 | $this->raw_headers = $headers; |
| 37 | 35 | $this->raw_body = $body; |
@@ -58,16 +56,14 @@ discard block |
||
| 58 | 56 | * |
| 59 | 57 | * @return bool Did we receive a 4xx or 5xx? |
| 60 | 58 | */ |
| 61 | - public function hasErrors() |
|
| 62 | - { |
|
| 59 | + public function hasErrors() { |
|
| 63 | 60 | return $this->code >= 400; |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | /** |
| 67 | 64 | * @return return bool |
| 68 | 65 | */ |
| 69 | - public function hasBody() |
|
| 70 | - { |
|
| 66 | + public function hasBody() { |
|
| 71 | 67 | return !empty($this->body); |
| 72 | 68 | } |
| 73 | 69 | |
@@ -78,8 +74,7 @@ discard block |
||
| 78 | 74 | * @return array|string|object the response parse accordingly |
| 79 | 75 | * @param string Http response body |
| 80 | 76 | */ |
| 81 | - public function _parse($body) |
|
| 82 | - { |
|
| 77 | + public function _parse($body) { |
|
| 83 | 78 | // If the user decided to forgo the automatic |
| 84 | 79 | // smart parsing, short circuit. |
| 85 | 80 | if (!$this->request->auto_parse) { |
@@ -112,8 +107,7 @@ discard block |
||
| 112 | 107 | * @return array parse headers |
| 113 | 108 | * @param string $headers raw headers |
| 114 | 109 | */ |
| 115 | - public function _parseHeaders($headers) |
|
| 116 | - { |
|
| 110 | + public function _parseHeaders($headers) { |
|
| 117 | 111 | $headers = preg_split("/(\r|\n)+/", $headers, -1, \PREG_SPLIT_NO_EMPTY); |
| 118 | 112 | $parse_headers = array(); |
| 119 | 113 | for ($i = 1; $i < count($headers); $i++) { |
@@ -134,10 +128,11 @@ discard block |
||
| 134 | 128 | return $parse_headers; |
| 135 | 129 | } |
| 136 | 130 | |
| 137 | - public function _parseCode($headers) |
|
| 138 | - { |
|
| 131 | + public function _parseCode($headers) { |
|
| 139 | 132 | $end = strpos($headers, "\r\n"); |
| 140 | - if ($end === false) $end = strlen($headers); |
|
| 133 | + if ($end === false) { |
|
| 134 | + $end = strlen($headers); |
|
| 135 | + } |
|
| 141 | 136 | $parts = explode(' ', substr($headers, 0, $end)); |
| 142 | 137 | if (count($parts) < 2 || !is_numeric($parts[1])) { |
| 143 | 138 | throw new \Exception("Unable to parse response code from HTTP response due to malformed response"); |
@@ -149,8 +144,7 @@ discard block |
||
| 149 | 144 | * After we've parse the headers, let's clean things |
| 150 | 145 | * up a bit and treat some headers specially |
| 151 | 146 | */ |
| 152 | - public function _interpretHeaders() |
|
| 153 | - { |
|
| 147 | + public function _interpretHeaders() { |
|
| 154 | 148 | // Parse the Content-Type and charset |
| 155 | 149 | $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : ''; |
| 156 | 150 | $content_type = explode(';', $content_type); |
@@ -187,8 +181,7 @@ discard block |
||
| 187 | 181 | /** |
| 188 | 182 | * @return string |
| 189 | 183 | */ |
| 190 | - public function __toString() |
|
| 191 | - { |
|
| 184 | + public function __toString() { |
|
| 192 | 185 | return $this->raw_body; |
| 193 | 186 | } |
| 194 | 187 | } |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | $parent_type, |
| 21 | 21 | $charset, |
| 22 | 22 | $meta_data, |
| 23 | - $is_mime_vendor_specific = false, |
|
| 24 | - $is_mime_personal = false; |
|
| 23 | + $is_mime_vendor_specific = FALSE, |
|
| 24 | + $is_mime_personal = FALSE; |
|
| 25 | 25 | |
| 26 | 26 | private $parsers; |
| 27 | 27 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function _parseCode($headers) |
| 138 | 138 | { |
| 139 | 139 | $end = strpos($headers, "\r\n"); |
| 140 | - if ($end === false) $end = strlen($headers); |
|
| 140 | + if ($end === FALSE) $end = strlen($headers); |
|
| 141 | 141 | $parts = explode(' ', substr($headers, 0, $end)); |
| 142 | 142 | if (count($parts) < 2 || !is_numeric($parts[1])) { |
| 143 | 143 | throw new \Exception("Unable to parse response code from HTTP response due to malformed response"); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $content_type = explode(';', $content_type); |
| 157 | 157 | |
| 158 | 158 | $this->content_type = $content_type[0]; |
| 159 | - if (count($content_type) == 2 && strpos($content_type[1], '=') !== false) { |
|
| 159 | + if (count($content_type) == 2 && strpos($content_type[1], '=') !== FALSE) { |
|
| 160 | 160 | list($nill, $this->charset) = explode('=', $content_type[1]); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // Is vendor type? Is personal type? |
| 173 | - if (strpos($this->content_type, '/') !== false) { |
|
| 173 | + if (strpos($this->content_type, '/') !== FALSE) { |
|
| 174 | 174 | list($type, $sub_type) = explode('/', $this->content_type); |
| 175 | 175 | $this->is_mime_vendor_specific = substr($sub_type, 0, 4) === 'vnd.'; |
| 176 | 176 | $this->is_mime_personal = substr($sub_type, 0, 4) === 'prs.'; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | // Parent type (e.g. xml for application/vnd.github.message+xml) |
| 180 | 180 | $this->parent_type = $this->content_type; |
| 181 | - if (strpos($this->content_type, '+') !== false) { |
|
| 181 | + if (strpos($this->content_type, '+') !== FALSE) { |
|
| 182 | 182 | list($vendor, $this->parent_type) = explode('+', $this->content_type, 2); |
| 183 | 183 | $this->parent_type = Mime::getFullMime($this->parent_type); |
| 184 | 184 | } |
@@ -29,24 +29,24 @@ discard block |
||
| 29 | 29 | const MAX_REDIRECTS_DEFAULT = 25; |
| 30 | 30 | |
| 31 | 31 | public $uri, |
| 32 | - $method = Http::GET, |
|
| 33 | - $headers = array(), |
|
| 34 | - $raw_headers = '', |
|
| 35 | - $strict_ssl = false, |
|
| 36 | - $content_type, |
|
| 37 | - $expected_type, |
|
| 38 | - $additional_curl_opts = array(), |
|
| 39 | - $auto_parse = true, |
|
| 40 | - $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
|
| 41 | - $username, |
|
| 42 | - $password, |
|
| 43 | - $serialized_payload, |
|
| 44 | - $payload, |
|
| 45 | - $parse_callback, |
|
| 46 | - $error_callback, |
|
| 47 | - $follow_redirects = false, |
|
| 48 | - $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
|
| 49 | - $payload_serializers = array(); |
|
| 32 | + $method = Http::GET, |
|
| 33 | + $headers = array(), |
|
| 34 | + $raw_headers = '', |
|
| 35 | + $strict_ssl = false, |
|
| 36 | + $content_type, |
|
| 37 | + $expected_type, |
|
| 38 | + $additional_curl_opts = array(), |
|
| 39 | + $auto_parse = true, |
|
| 40 | + $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
|
| 41 | + $username, |
|
| 42 | + $password, |
|
| 43 | + $serialized_payload, |
|
| 44 | + $payload, |
|
| 45 | + $parse_callback, |
|
| 46 | + $error_callback, |
|
| 47 | + $follow_redirects = false, |
|
| 48 | + $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
|
| 49 | + $payload_serializers = array(); |
|
| 50 | 50 | |
| 51 | 51 | // Options |
| 52 | 52 | // private $_options = array( |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | // Curl Handle |
| 58 | 58 | public $_ch, |
| 59 | - $_debug; |
|
| 59 | + $_debug; |
|
| 60 | 60 | |
| 61 | 61 | // Template Request object |
| 62 | 62 | private static $_template; |
@@ -807,10 +807,10 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | $request = new Request(); |
| 809 | 809 | return $request |
| 810 | - ->_setDefaults() |
|
| 811 | - ->method($method) |
|
| 812 | - ->sendsType($mime) |
|
| 813 | - ->expectsType($mime); |
|
| 810 | + ->_setDefaults() |
|
| 811 | + ->method($method) |
|
| 812 | + ->sendsType($mime) |
|
| 813 | + ->expectsType($mime); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | /** |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public $uri, |
| 32 | 32 | $method = Http::GET, |
| 33 | - $headers = array(), |
|
| 33 | + $headers = array (), |
|
| 34 | 34 | $raw_headers = '', |
| 35 | 35 | $strict_ssl = false, |
| 36 | 36 | $content_type, |
| 37 | 37 | $expected_type, |
| 38 | - $additional_curl_opts = array(), |
|
| 38 | + $additional_curl_opts = array (), |
|
| 39 | 39 | $auto_parse = true, |
| 40 | 40 | $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
| 41 | 41 | $username, |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $error_callback, |
| 47 | 47 | $follow_redirects = false, |
| 48 | 48 | $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
| 49 | - $payload_serializers = array(); |
|
| 49 | + $payload_serializers = array (); |
|
| 50 | 50 | |
| 51 | 51 | // Options |
| 52 | 52 | // private $_options = array( |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | public function contentType($mime) |
| 413 | 413 | { |
| 414 | 414 | if (empty($mime)) return $this; |
| 415 | - $this->content_type = Mime::getFullMime($mime); |
|
| 415 | + $this->content_type = Mime::getFullMime($mime); |
|
| 416 | 416 | if ($this->isUpload()) { |
| 417 | 417 | $this->neverSerializePayload(); |
| 418 | 418 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | { |
| 462 | 462 | $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}"); |
| 463 | 463 | $this->addOnCurlOption(CURLOPT_PROXYTYPE, $proxy_type); |
| 464 | - if (in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM))) { |
|
| 464 | + if (in_array($auth_type, array (CURLAUTH_BASIC, CURLAUTH_NTLM))) { |
|
| 465 | 465 | $this->addOnCurlOption(CURLOPT_PROXYAUTH, $auth_type) |
| 466 | 466 | ->addOnCurlOption(CURLOPT_PROXYUSERPWD, "{$auth_username}:{$auth_password}"); |
| 467 | 467 | } |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | // recusion. Do not use this syntax elsewhere. |
| 755 | 755 | // It goes against the whole readability |
| 756 | 756 | // and transparency idea. |
| 757 | - self::$_template = new Request(array('method' => Http::GET)); |
|
| 757 | + self::$_template = new Request(array ('method' => Http::GET)); |
|
| 758 | 758 | |
| 759 | 759 | // This is more like it... |
| 760 | 760 | self::$_template |
@@ -844,11 +844,11 @@ discard block |
||
| 844 | 844 | if (!file_exists($this->client_cert)) |
| 845 | 845 | throw new \Exception('Could not read Client Certificate'); |
| 846 | 846 | |
| 847 | - curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
| 848 | - curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
| 849 | - curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
| 850 | - curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
| 851 | - curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
| 847 | + curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
|
| 848 | + curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
|
| 849 | + curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert); |
|
| 850 | + curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key); |
|
| 851 | + curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase); |
|
| 852 | 852 | // curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->client_cert_passphrase); |
| 853 | 853 | } |
| 854 | 854 | |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $headers = array(); |
|
| 887 | + $headers = array (); |
|
| 888 | 888 | // https://github.com/nategood/httpful/issues/37 |
| 889 | 889 | // Except header removes any HTTP 1.1 Continue from response headers |
| 890 | 890 | $headers[] = 'Expect:'; |
@@ -917,9 +917,9 @@ discard block |
||
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | $url = \parse_url($this->uri); |
| 920 | - $path = (isset($url['path']) ? $url['path'] : '/').(isset($url['query']) ? '?'.$url['query'] : ''); |
|
| 920 | + $path = (isset($url['path']) ? $url['path'] : '/') . (isset($url['query']) ? '?' . $url['query'] : ''); |
|
| 921 | 921 | $this->raw_headers = "{$this->method} $path HTTP/1.1\r\n"; |
| 922 | - $host = (isset($url['host']) ? $url['host'] : 'localhost').(isset($url['port']) ? ':'.$url['port'] : ''); |
|
| 922 | + $host = (isset($url['host']) ? $url['host'] : 'localhost') . (isset($url['port']) ? ':' . $url['port'] : ''); |
|
| 923 | 923 | $this->raw_headers .= "Host: $host\r\n"; |
| 924 | 924 | $this->raw_headers .= \implode("\r\n", $headers); |
| 925 | 925 | $this->raw_headers .= "\r\n"; |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | $user_agent .= '?.?.?'; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - $user_agent .= ' PHP/'. PHP_VERSION . ' (' . PHP_OS . ')'; |
|
| 981 | + $user_agent .= ' PHP/' . PHP_VERSION . ' (' . PHP_OS . ')'; |
|
| 982 | 982 | |
| 983 | 983 | if (isset($_SERVER['SERVER_SOFTWARE'])) { |
| 984 | 984 | $user_agent .= ' ' . \preg_replace('~PHP/[\d\.]+~U', '', |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @author Nate Good <[email protected]> |
| 20 | 20 | */ |
| 21 | -class Request |
|
| 22 | -{ |
|
| 21 | +class Request { |
|
| 23 | 22 | |
| 24 | 23 | // Option constants |
| 25 | 24 | const SERIALIZE_PAYLOAD_NEVER = 0; |
@@ -68,9 +67,10 @@ discard block |
||
| 68 | 67 | * for internal use. |
| 69 | 68 | * @param array $attrs hash of initial attribute values |
| 70 | 69 | */ |
| 71 | - private function __construct($attrs = null) |
|
| 72 | - { |
|
| 73 | - if (!is_array($attrs)) return; |
|
| 70 | + private function __construct($attrs = null) { |
|
| 71 | + if (!is_array($attrs)) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 74 | 74 | foreach ($attrs as $attr => $value) { |
| 75 | 75 | $this->$attr = $value; |
| 76 | 76 | } |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | * scheme of things as it typically only occurs once |
| 91 | 91 | * @param Request $template |
| 92 | 92 | */ |
| 93 | - public static function ini(Request $template) |
|
| 94 | - { |
|
| 93 | + public static function ini(Request $template) { |
|
| 95 | 94 | self::$_template = clone $template; |
| 96 | 95 | } |
| 97 | 96 | |
@@ -99,8 +98,7 @@ discard block |
||
| 99 | 98 | * Reset the default template back to the |
| 100 | 99 | * library defaults. |
| 101 | 100 | */ |
| 102 | - public static function resetIni() |
|
| 103 | - { |
|
| 101 | + public static function resetIni() { |
|
| 104 | 102 | self::_initializeDefaults(); |
| 105 | 103 | } |
| 106 | 104 | |
@@ -110,8 +108,7 @@ discard block |
||
| 110 | 108 | * @param string|null $attr Name of attribute (e.g. mime, headers) |
| 111 | 109 | * if null just return the whole template object; |
| 112 | 110 | */ |
| 113 | - public static function d($attr) |
|
| 114 | - { |
|
| 111 | + public static function d($attr) { |
|
| 115 | 112 | return isset($attr) ? self::$_template->$attr : self::$_template; |
| 116 | 113 | } |
| 117 | 114 | |
@@ -120,32 +117,28 @@ discard block |
||
| 120 | 117 | /** |
| 121 | 118 | * @return bool does the request have a timeout? |
| 122 | 119 | */ |
| 123 | - public function hasTimeout() |
|
| 124 | - { |
|
| 120 | + public function hasTimeout() { |
|
| 125 | 121 | return isset($this->timeout); |
| 126 | 122 | } |
| 127 | 123 | |
| 128 | 124 | /** |
| 129 | 125 | * @return bool has the internal curl request been initialized? |
| 130 | 126 | */ |
| 131 | - public function hasBeenInitialized() |
|
| 132 | - { |
|
| 127 | + public function hasBeenInitialized() { |
|
| 133 | 128 | return isset($this->_ch); |
| 134 | 129 | } |
| 135 | 130 | |
| 136 | 131 | /** |
| 137 | 132 | * @return bool Is this request setup for basic auth? |
| 138 | 133 | */ |
| 139 | - public function hasBasicAuth() |
|
| 140 | - { |
|
| 134 | + public function hasBasicAuth() { |
|
| 141 | 135 | return isset($this->password) && isset($this->username); |
| 142 | 136 | } |
| 143 | 137 | |
| 144 | 138 | /** |
| 145 | 139 | * @return bool Is this request setup for digest auth? |
| 146 | 140 | */ |
| 147 | - public function hasDigestAuth() |
|
| 148 | - { |
|
| 141 | + public function hasDigestAuth() { |
|
| 149 | 142 | return isset($this->password) && isset($this->username) && $this->additional_curl_opts[CURLOPT_HTTPAUTH] == CURLAUTH_DIGEST; |
| 150 | 143 | } |
| 151 | 144 | |
@@ -154,15 +147,13 @@ discard block |
||
| 154 | 147 | * @return Request $this |
| 155 | 148 | * @param float|int $timeout seconds to timeout the HTTP call |
| 156 | 149 | */ |
| 157 | - public function timeout($timeout) |
|
| 158 | - { |
|
| 150 | + public function timeout($timeout) { |
|
| 159 | 151 | $this->timeout = $timeout; |
| 160 | 152 | return $this; |
| 161 | 153 | } |
| 162 | 154 | |
| 163 | 155 | // alias timeout |
| 164 | - public function timeoutIn($seconds) |
|
| 165 | - { |
|
| 156 | + public function timeoutIn($seconds) { |
|
| 166 | 157 | return $this->timeout($seconds); |
| 167 | 158 | } |
| 168 | 159 | |
@@ -172,8 +163,7 @@ discard block |
||
| 172 | 163 | * @return Request $this |
| 173 | 164 | * @param bool|int $follow follow or not to follow or maximal number of redirects |
| 174 | 165 | */ |
| 175 | - public function followRedirects($follow = true) |
|
| 176 | - { |
|
| 166 | + public function followRedirects($follow = true) { |
|
| 177 | 167 | $this->max_redirects = $follow === true ? self::MAX_REDIRECTS_DEFAULT : max(0, $follow); |
| 178 | 168 | $this->follow_redirects = (bool) $follow; |
| 179 | 169 | return $this; |
@@ -183,8 +173,7 @@ discard block |
||
| 183 | 173 | * @return Request $this |
| 184 | 174 | * @see Request::followRedirects() |
| 185 | 175 | */ |
| 186 | - public function doNotFollowRedirects() |
|
| 187 | - { |
|
| 176 | + public function doNotFollowRedirects() { |
|
| 188 | 177 | return $this->followRedirects(false); |
| 189 | 178 | } |
| 190 | 179 | |
@@ -193,10 +182,10 @@ discard block |
||
| 193 | 182 | * @return string|associative array of parsed results |
| 194 | 183 | * @throws ConnectionErrorException when unable to parse or communicate w server |
| 195 | 184 | */ |
| 196 | - public function send() |
|
| 197 | - { |
|
| 198 | - if (!$this->hasBeenInitialized()) |
|
| 199 | - $this->_curlPrep(); |
|
| 185 | + public function send() { |
|
| 186 | + if (!$this->hasBeenInitialized()) { |
|
| 187 | + $this->_curlPrep(); |
|
| 188 | + } |
|
| 200 | 189 | |
| 201 | 190 | $result = curl_exec($this->_ch); |
| 202 | 191 | |
@@ -228,8 +217,7 @@ discard block |
||
| 228 | 217 | |
| 229 | 218 | return new Response($body, $headers, $this, $info); |
| 230 | 219 | } |
| 231 | - public function sendIt() |
|
| 232 | - { |
|
| 220 | + public function sendIt() { |
|
| 233 | 221 | return $this->send(); |
| 234 | 222 | } |
| 235 | 223 | |
@@ -239,8 +227,7 @@ discard block |
||
| 239 | 227 | * @return Request this |
| 240 | 228 | * @param string $uri |
| 241 | 229 | */ |
| 242 | - public function uri($uri) |
|
| 243 | - { |
|
| 230 | + public function uri($uri) { |
|
| 244 | 231 | $this->uri = $uri; |
| 245 | 232 | return $this; |
| 246 | 233 | } |
@@ -252,20 +239,17 @@ discard block |
||
| 252 | 239 | * @param string $username |
| 253 | 240 | * @param string $password |
| 254 | 241 | */ |
| 255 | - public function basicAuth($username, $password) |
|
| 256 | - { |
|
| 242 | + public function basicAuth($username, $password) { |
|
| 257 | 243 | $this->username = $username; |
| 258 | 244 | $this->password = $password; |
| 259 | 245 | return $this; |
| 260 | 246 | } |
| 261 | 247 | // @alias of basicAuth |
| 262 | - public function authenticateWith($username, $password) |
|
| 263 | - { |
|
| 248 | + public function authenticateWith($username, $password) { |
|
| 264 | 249 | return $this->basicAuth($username, $password); |
| 265 | 250 | } |
| 266 | 251 | // @alias of basicAuth |
| 267 | - public function authenticateWithBasic($username, $password) |
|
| 268 | - { |
|
| 252 | + public function authenticateWithBasic($username, $password) { |
|
| 269 | 253 | return $this->basicAuth($username, $password); |
| 270 | 254 | } |
| 271 | 255 | |
@@ -275,23 +259,20 @@ discard block |
||
| 275 | 259 | * @param string $username |
| 276 | 260 | * @param string $password |
| 277 | 261 | */ |
| 278 | - public function digestAuth($username, $password) |
|
| 279 | - { |
|
| 262 | + public function digestAuth($username, $password) { |
|
| 280 | 263 | $this->addOnCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); |
| 281 | 264 | return $this->basicAuth($username, $password); |
| 282 | 265 | } |
| 283 | 266 | |
| 284 | 267 | // @alias of digestAuth |
| 285 | - public function authenticateWithDigest($username, $password) |
|
| 286 | - { |
|
| 268 | + public function authenticateWithDigest($username, $password) { |
|
| 287 | 269 | return $this->digestAuth($username, $password); |
| 288 | 270 | } |
| 289 | 271 | |
| 290 | 272 | /** |
| 291 | 273 | * @return is this request setup for client side cert? |
| 292 | 274 | */ |
| 293 | - public function hasClientSideCert() |
|
| 294 | - { |
|
| 275 | + public function hasClientSideCert() { |
|
| 295 | 276 | return isset($this->client_cert) && isset($this->client_key); |
| 296 | 277 | } |
| 297 | 278 | |
@@ -303,8 +284,7 @@ discard block |
||
| 303 | 284 | * @param string $passphrase for client key |
| 304 | 285 | * @param string $encoding default PEM |
| 305 | 286 | */ |
| 306 | - public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM') |
|
| 307 | - { |
|
| 287 | + public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM') { |
|
| 308 | 288 | $this->client_cert = $cert; |
| 309 | 289 | $this->client_key = $key; |
| 310 | 290 | $this->client_passphrase = $passphrase; |
@@ -313,8 +293,7 @@ discard block |
||
| 313 | 293 | return $this; |
| 314 | 294 | } |
| 315 | 295 | // @alias of basicAuth |
| 316 | - public function authenticateWithCert($cert, $key, $passphrase = null, $encoding = 'PEM') |
|
| 317 | - { |
|
| 296 | + public function authenticateWithCert($cert, $key, $passphrase = null, $encoding = 'PEM') { |
|
| 318 | 297 | return $this->clientSideCert($cert, $key, $passphrase, $encoding); |
| 319 | 298 | } |
| 320 | 299 | |
@@ -325,8 +304,7 @@ discard block |
||
| 325 | 304 | * @param string $mimeType currently, sets the sends AND expects mime type although this |
| 326 | 305 | * behavior may change in the next minor release (as it is a potential breaking change). |
| 327 | 306 | */ |
| 328 | - public function body($payload, $mimeType = null) |
|
| 329 | - { |
|
| 307 | + public function body($payload, $mimeType = null) { |
|
| 330 | 308 | $this->mime($mimeType); |
| 331 | 309 | $this->payload = $payload; |
| 332 | 310 | // Iserntentially don't call _serializePayload yet. Wait until |
@@ -341,9 +319,10 @@ discard block |
||
| 341 | 319 | * @return Request this |
| 342 | 320 | * @param string $mime mime type to use for content type and expected return type |
| 343 | 321 | */ |
| 344 | - public function mime($mime) |
|
| 345 | - { |
|
| 346 | - if (empty($mime)) return $this; |
|
| 322 | + public function mime($mime) { |
|
| 323 | + if (empty($mime)) { |
|
| 324 | + return $this; |
|
| 325 | + } |
|
| 347 | 326 | $this->content_type = $this->expected_type = Mime::getFullMime($mime); |
| 348 | 327 | if ($this->isUpload()) { |
| 349 | 328 | $this->neverSerializePayload(); |
@@ -351,13 +330,11 @@ discard block |
||
| 351 | 330 | return $this; |
| 352 | 331 | } |
| 353 | 332 | // @alias of mime |
| 354 | - public function sendsAndExpectsType($mime) |
|
| 355 | - { |
|
| 333 | + public function sendsAndExpectsType($mime) { |
|
| 356 | 334 | return $this->mime($mime); |
| 357 | 335 | } |
| 358 | 336 | // @alias of mime |
| 359 | - public function sendsAndExpects($mime) |
|
| 360 | - { |
|
| 337 | + public function sendsAndExpects($mime) { |
|
| 361 | 338 | return $this->mime($mime); |
| 362 | 339 | } |
| 363 | 340 | |
@@ -367,9 +344,10 @@ discard block |
||
| 367 | 344 | * @return Request this |
| 368 | 345 | * @param string $method |
| 369 | 346 | */ |
| 370 | - public function method($method) |
|
| 371 | - { |
|
| 372 | - if (empty($method)) return $this; |
|
| 347 | + public function method($method) { |
|
| 348 | + if (empty($method)) { |
|
| 349 | + return $this; |
|
| 350 | + } |
|
| 373 | 351 | $this->method = $method; |
| 374 | 352 | return $this; |
| 375 | 353 | } |
@@ -378,20 +356,19 @@ discard block |
||
| 378 | 356 | * @return Request this |
| 379 | 357 | * @param string $mime |
| 380 | 358 | */ |
| 381 | - public function expects($mime) |
|
| 382 | - { |
|
| 383 | - if (empty($mime)) return $this; |
|
| 359 | + public function expects($mime) { |
|
| 360 | + if (empty($mime)) { |
|
| 361 | + return $this; |
|
| 362 | + } |
|
| 384 | 363 | $this->expected_type = Mime::getFullMime($mime); |
| 385 | 364 | return $this; |
| 386 | 365 | } |
| 387 | 366 | // @alias of expects |
| 388 | - public function expectsType($mime) |
|
| 389 | - { |
|
| 367 | + public function expectsType($mime) { |
|
| 390 | 368 | return $this->expects($mime); |
| 391 | 369 | } |
| 392 | 370 | |
| 393 | - public function attach($files) |
|
| 394 | - { |
|
| 371 | + public function attach($files) { |
|
| 395 | 372 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 396 | 373 | foreach ($files as $key => $file) { |
| 397 | 374 | $mimeType = finfo_file($finfo, $file); |
@@ -409,9 +386,10 @@ discard block |
||
| 409 | 386 | * @return Request this |
| 410 | 387 | * @param string $mime |
| 411 | 388 | */ |
| 412 | - public function contentType($mime) |
|
| 413 | - { |
|
| 414 | - if (empty($mime)) return $this; |
|
| 389 | + public function contentType($mime) { |
|
| 390 | + if (empty($mime)) { |
|
| 391 | + return $this; |
|
| 392 | + } |
|
| 415 | 393 | $this->content_type = Mime::getFullMime($mime); |
| 416 | 394 | if ($this->isUpload()) { |
| 417 | 395 | $this->neverSerializePayload(); |
@@ -419,13 +397,11 @@ discard block |
||
| 419 | 397 | return $this; |
| 420 | 398 | } |
| 421 | 399 | // @alias of contentType |
| 422 | - public function sends($mime) |
|
| 423 | - { |
|
| 400 | + public function sends($mime) { |
|
| 424 | 401 | return $this->contentType($mime); |
| 425 | 402 | } |
| 426 | 403 | // @alias of contentType |
| 427 | - public function sendsType($mime) |
|
| 428 | - { |
|
| 404 | + public function sendsType($mime) { |
|
| 429 | 405 | return $this->contentType($mime); |
| 430 | 406 | } |
| 431 | 407 | |
@@ -434,17 +410,14 @@ discard block |
||
| 434 | 410 | * @return Request this |
| 435 | 411 | * @param bool $strict |
| 436 | 412 | */ |
| 437 | - public function strictSSL($strict) |
|
| 438 | - { |
|
| 413 | + public function strictSSL($strict) { |
|
| 439 | 414 | $this->strict_ssl = $strict; |
| 440 | 415 | return $this; |
| 441 | 416 | } |
| 442 | - public function withoutStrictSSL() |
|
| 443 | - { |
|
| 417 | + public function withoutStrictSSL() { |
|
| 444 | 418 | return $this->strictSSL(false); |
| 445 | 419 | } |
| 446 | - public function withStrictSSL() |
|
| 447 | - { |
|
| 420 | + public function withStrictSSL() { |
|
| 448 | 421 | return $this->strictSSL(true); |
| 449 | 422 | } |
| 450 | 423 | |
@@ -457,8 +430,7 @@ discard block |
||
| 457 | 430 | * @param string $auth_username Authentication username. Default null |
| 458 | 431 | * @param string $auth_password Authentication password. Default null |
| 459 | 432 | */ |
| 460 | - public function useProxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null, $proxy_type = Proxy::HTTP) |
|
| 461 | - { |
|
| 433 | + public function useProxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null, $proxy_type = Proxy::HTTP) { |
|
| 462 | 434 | $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}"); |
| 463 | 435 | $this->addOnCurlOption(CURLOPT_PROXYTYPE, $proxy_type); |
| 464 | 436 | if (in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM))) { |
@@ -473,8 +445,7 @@ discard block |
||
| 473 | 445 | * @see Request::useProxy |
| 474 | 446 | * @return Request |
| 475 | 447 | */ |
| 476 | - public function useSocks4Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) |
|
| 477 | - { |
|
| 448 | + public function useSocks4Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) { |
|
| 478 | 449 | return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS4); |
| 479 | 450 | } |
| 480 | 451 | |
@@ -483,16 +454,14 @@ discard block |
||
| 483 | 454 | * @see Request::useProxy |
| 484 | 455 | * @return Request |
| 485 | 456 | */ |
| 486 | - public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) |
|
| 487 | - { |
|
| 457 | + public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) { |
|
| 488 | 458 | return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS5); |
| 489 | 459 | } |
| 490 | 460 | |
| 491 | 461 | /** |
| 492 | 462 | * @return is this request setup for using proxy? |
| 493 | 463 | */ |
| 494 | - public function hasProxy() |
|
| 495 | - { |
|
| 464 | + public function hasProxy() { |
|
| 496 | 465 | return isset($this->additional_curl_opts[CURLOPT_PROXY]) && is_string($this->additional_curl_opts[CURLOPT_PROXY]); |
| 497 | 466 | } |
| 498 | 467 | |
@@ -517,8 +486,7 @@ discard block |
||
| 517 | 486 | * @return Request $this |
| 518 | 487 | * @param int $mode |
| 519 | 488 | */ |
| 520 | - public function serializePayload($mode) |
|
| 521 | - { |
|
| 489 | + public function serializePayload($mode) { |
|
| 522 | 490 | $this->serialize_payload_method = $mode; |
| 523 | 491 | return $this; |
| 524 | 492 | } |
@@ -527,8 +495,7 @@ discard block |
||
| 527 | 495 | * @see Request::serializePayload() |
| 528 | 496 | * @return Request |
| 529 | 497 | */ |
| 530 | - public function neverSerializePayload() |
|
| 531 | - { |
|
| 498 | + public function neverSerializePayload() { |
|
| 532 | 499 | return $this->serializePayload(self::SERIALIZE_PAYLOAD_NEVER); |
| 533 | 500 | } |
| 534 | 501 | |
@@ -537,8 +504,7 @@ discard block |
||
| 537 | 504 | * @see Request::serializePayload() |
| 538 | 505 | * @return Request |
| 539 | 506 | */ |
| 540 | - public function smartSerializePayload() |
|
| 541 | - { |
|
| 507 | + public function smartSerializePayload() { |
|
| 542 | 508 | return $this->serializePayload(self::SERIALIZE_PAYLOAD_SMART); |
| 543 | 509 | } |
| 544 | 510 | |
@@ -546,8 +512,7 @@ discard block |
||
| 546 | 512 | * @see Request::serializePayload() |
| 547 | 513 | * @return Request |
| 548 | 514 | */ |
| 549 | - public function alwaysSerializePayload() |
|
| 550 | - { |
|
| 515 | + public function alwaysSerializePayload() { |
|
| 551 | 516 | return $this->serializePayload(self::SERIALIZE_PAYLOAD_ALWAYS); |
| 552 | 517 | } |
| 553 | 518 | |
@@ -561,8 +526,7 @@ discard block |
||
| 561 | 526 | * @param string $header_name |
| 562 | 527 | * @param string $value |
| 563 | 528 | */ |
| 564 | - public function addHeader($header_name, $value) |
|
| 565 | - { |
|
| 529 | + public function addHeader($header_name, $value) { |
|
| 566 | 530 | $this->headers[$header_name] = $value; |
| 567 | 531 | return $this; |
| 568 | 532 | } |
@@ -575,8 +539,7 @@ discard block |
||
| 575 | 539 | * @return Request $this |
| 576 | 540 | * @param array $headers |
| 577 | 541 | */ |
| 578 | - public function addHeaders(array $headers) |
|
| 579 | - { |
|
| 542 | + public function addHeaders(array $headers) { |
|
| 580 | 543 | foreach ($headers as $header => $value) { |
| 581 | 544 | $this->addHeader($header, $value); |
| 582 | 545 | } |
@@ -590,8 +553,7 @@ discard block |
||
| 590 | 553 | * If not auto parsing, Response->body returns the body |
| 591 | 554 | * as a string. |
| 592 | 555 | */ |
| 593 | - public function autoParse($auto_parse = true) |
|
| 594 | - { |
|
| 556 | + public function autoParse($auto_parse = true) { |
|
| 595 | 557 | $this->auto_parse = $auto_parse; |
| 596 | 558 | return $this; |
| 597 | 559 | } |
@@ -600,8 +562,7 @@ discard block |
||
| 600 | 562 | * @see Request::autoParse() |
| 601 | 563 | * @return Request |
| 602 | 564 | */ |
| 603 | - public function withoutAutoParsing() |
|
| 604 | - { |
|
| 565 | + public function withoutAutoParsing() { |
|
| 605 | 566 | return $this->autoParse(false); |
| 606 | 567 | } |
| 607 | 568 | |
@@ -609,8 +570,7 @@ discard block |
||
| 609 | 570 | * @see Request::autoParse() |
| 610 | 571 | * @return Request |
| 611 | 572 | */ |
| 612 | - public function withAutoParsing() |
|
| 613 | - { |
|
| 573 | + public function withAutoParsing() { |
|
| 614 | 574 | return $this->autoParse(true); |
| 615 | 575 | } |
| 616 | 576 | |
@@ -620,8 +580,7 @@ discard block |
||
| 620 | 580 | * @param \Closure $callback Takes the raw body of |
| 621 | 581 | * the http response and returns a mixed |
| 622 | 582 | */ |
| 623 | - public function parseWith(\Closure $callback) |
|
| 624 | - { |
|
| 583 | + public function parseWith(\Closure $callback) { |
|
| 625 | 584 | $this->parse_callback = $callback; |
| 626 | 585 | return $this; |
| 627 | 586 | } |
@@ -631,8 +590,7 @@ discard block |
||
| 631 | 590 | * @return Request $this |
| 632 | 591 | * @param \Closure $callback |
| 633 | 592 | */ |
| 634 | - public function parseResponsesWith(\Closure $callback) |
|
| 635 | - { |
|
| 593 | + public function parseResponsesWith(\Closure $callback) { |
|
| 636 | 594 | return $this->parseWith($callback); |
| 637 | 595 | } |
| 638 | 596 | |
@@ -642,8 +600,7 @@ discard block |
||
| 642 | 600 | * @return Request |
| 643 | 601 | * @param \Closure $callback (string $error) |
| 644 | 602 | */ |
| 645 | - public function whenError(\Closure $callback) |
|
| 646 | - { |
|
| 603 | + public function whenError(\Closure $callback) { |
|
| 647 | 604 | $this->error_callback = $callback; |
| 648 | 605 | return $this; |
| 649 | 606 | } |
@@ -660,8 +617,7 @@ discard block |
||
| 660 | 617 | * @param Closure $callback takes one argument, $payload, |
| 661 | 618 | * which is the payload that we'll be |
| 662 | 619 | */ |
| 663 | - public function registerPayloadSerializer($mime, \Closure $callback) |
|
| 664 | - { |
|
| 620 | + public function registerPayloadSerializer($mime, \Closure $callback) { |
|
| 665 | 621 | $this->payload_serializers[Mime::getFullMime($mime)] = $callback; |
| 666 | 622 | return $this; |
| 667 | 623 | } |
@@ -671,8 +627,7 @@ discard block |
||
| 671 | 627 | * @return Request $this |
| 672 | 628 | * @param Closure $callback |
| 673 | 629 | */ |
| 674 | - public function serializePayloadWith(\Closure $callback) |
|
| 675 | - { |
|
| 630 | + public function serializePayloadWith(\Closure $callback) { |
|
| 676 | 631 | return $this->registerPayloadSerializer('*', $callback); |
| 677 | 632 | } |
| 678 | 633 | |
@@ -691,8 +646,7 @@ discard block |
||
| 691 | 646 | * @param array $args in this case, there should only ever be 1 argument provided |
| 692 | 647 | * and that argument should be a string value of the header we're setting |
| 693 | 648 | */ |
| 694 | - public function __call($method, $args) |
|
| 695 | - { |
|
| 649 | + public function __call($method, $args) { |
|
| 696 | 650 | // This method supports the sends* methods |
| 697 | 651 | // like sendsJSON, sendsForm |
| 698 | 652 | //!method_exists($this, $method) && |
@@ -719,15 +673,17 @@ discard block |
||
| 719 | 673 | |
| 720 | 674 | // This method also adds the custom header support as described in the |
| 721 | 675 | // method comments |
| 722 | - if (count($args) === 0) |
|
| 723 | - return; |
|
| 676 | + if (count($args) === 0) { |
|
| 677 | + return; |
|
| 678 | + } |
|
| 724 | 679 | |
| 725 | 680 | // Strip the sugar. If it leads with "with", strip. |
| 726 | 681 | // This is okay because: No defined HTTP headers begin with with, |
| 727 | 682 | // and if you are defining a custom header, the standard is to prefix it |
| 728 | 683 | // with an "X-", so that should take care of any collisions. |
| 729 | - if (substr($method, 0, 4) === 'with') |
|
| 730 | - $method = substr($method, 4); |
|
| 684 | + if (substr($method, 0, 4) === 'with') { |
|
| 685 | + $method = substr($method, 4); |
|
| 686 | + } |
|
| 731 | 687 | |
| 732 | 688 | // Precede upper case letters with dashes, uppercase the first letter of method |
| 733 | 689 | $header = ucwords(implode('-', preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); |
@@ -746,8 +702,7 @@ discard block |
||
| 746 | 702 | * Request instantiation), it promotes readability |
| 747 | 703 | * and flexibility within the class. |
| 748 | 704 | */ |
| 749 | - private static function _initializeDefaults() |
|
| 750 | - { |
|
| 705 | + private static function _initializeDefaults() { |
|
| 751 | 706 | // This is the only place you will |
| 752 | 707 | // see this constructor syntax. It |
| 753 | 708 | // is only done here to prevent infinite |
@@ -766,19 +721,19 @@ discard block |
||
| 766 | 721 | * Doesn't copy variables prefixed with _ |
| 767 | 722 | * @return Request this |
| 768 | 723 | */ |
| 769 | - private function _setDefaults() |
|
| 770 | - { |
|
| 771 | - if (!isset(self::$_template)) |
|
| 772 | - self::_initializeDefaults(); |
|
| 724 | + private function _setDefaults() { |
|
| 725 | + if (!isset(self::$_template)) { |
|
| 726 | + self::_initializeDefaults(); |
|
| 727 | + } |
|
| 773 | 728 | foreach (self::$_template as $k=>$v) { |
| 774 | - if ($k[0] != '_') |
|
| 775 | - $this->$k = $v; |
|
| 729 | + if ($k[0] != '_') { |
|
| 730 | + $this->$k = $v; |
|
| 731 | + } |
|
| 776 | 732 | } |
| 777 | 733 | return $this; |
| 778 | 734 | } |
| 779 | 735 | |
| 780 | - private function _error($error) |
|
| 781 | - { |
|
| 736 | + private function _error($error) { |
|
| 782 | 737 | // TODO add in support for various Loggers that follow |
| 783 | 738 | // PSR 3 https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md |
| 784 | 739 | if (isset($this->error_callback)) { |
@@ -796,14 +751,14 @@ discard block |
||
| 796 | 751 | * @param string $method Http Method |
| 797 | 752 | * @param string $mime Mime Type to Use |
| 798 | 753 | */ |
| 799 | - public static function init($method = null, $mime = null) |
|
| 800 | - { |
|
| 754 | + public static function init($method = null, $mime = null) { |
|
| 801 | 755 | // Setup our handlers, can call it here as it's idempotent |
| 802 | 756 | Bootstrap::init(); |
| 803 | 757 | |
| 804 | 758 | // Setup the default template if need be |
| 805 | - if (!isset(self::$_template)) |
|
| 806 | - self::_initializeDefaults(); |
|
| 759 | + if (!isset(self::$_template)) { |
|
| 760 | + self::_initializeDefaults(); |
|
| 761 | + } |
|
| 807 | 762 | |
| 808 | 763 | $request = new Request(); |
| 809 | 764 | return $request |
@@ -819,11 +774,11 @@ discard block |
||
| 819 | 774 | * Note: It does NOT actually send the request |
| 820 | 775 | * @return Request $this; |
| 821 | 776 | */ |
| 822 | - public function _curlPrep() |
|
| 823 | - { |
|
| 777 | + public function _curlPrep() { |
|
| 824 | 778 | // Check for required stuff |
| 825 | - if (!isset($this->uri)) |
|
| 826 | - throw new \Exception('Attempting to send a request before defining a URI endpoint.'); |
|
| 779 | + if (!isset($this->uri)) { |
|
| 780 | + throw new \Exception('Attempting to send a request before defining a URI endpoint.'); |
|
| 781 | + } |
|
| 827 | 782 | |
| 828 | 783 | $ch = curl_init($this->uri); |
| 829 | 784 | |
@@ -838,11 +793,13 @@ discard block |
||
| 838 | 793 | |
| 839 | 794 | if ($this->hasClientSideCert()) { |
| 840 | 795 | |
| 841 | - if (!file_exists($this->client_key)) |
|
| 842 | - throw new \Exception('Could not read Client Key'); |
|
| 796 | + if (!file_exists($this->client_key)) { |
|
| 797 | + throw new \Exception('Could not read Client Key'); |
|
| 798 | + } |
|
| 843 | 799 | |
| 844 | - if (!file_exists($this->client_cert)) |
|
| 845 | - throw new \Exception('Could not read Client Certificate'); |
|
| 800 | + if (!file_exists($this->client_cert)) { |
|
| 801 | + throw new \Exception('Could not read Client Certificate'); |
|
| 802 | + } |
|
| 846 | 803 | |
| 847 | 804 | curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding); |
| 848 | 805 | curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding); |
@@ -869,7 +826,9 @@ discard block |
||
| 869 | 826 | // zero is safe for all curl versions |
| 870 | 827 | $verifyValue = $this->strict_ssl + 0; |
| 871 | 828 | //Support for value 1 removed in cURL 7.28.1 value 2 valid in all versions |
| 872 | - if ($verifyValue > 0) $verifyValue++; |
|
| 829 | + if ($verifyValue > 0) { |
|
| 830 | + $verifyValue++; |
|
| 831 | + } |
|
| 873 | 832 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyValue); |
| 874 | 833 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 875 | 834 | |
@@ -947,8 +906,7 @@ discard block |
||
| 947 | 906 | * @return int length of payload in bytes |
| 948 | 907 | * @param string $str payload |
| 949 | 908 | */ |
| 950 | - public function _determineLength($str) |
|
| 951 | - { |
|
| 909 | + public function _determineLength($str) { |
|
| 952 | 910 | if (function_exists('mb_strlen')) { |
| 953 | 911 | return mb_strlen($str, '8bit'); |
| 954 | 912 | } else { |
@@ -959,16 +917,14 @@ discard block |
||
| 959 | 917 | /** |
| 960 | 918 | * @return bool |
| 961 | 919 | */ |
| 962 | - public function isUpload() |
|
| 963 | - { |
|
| 920 | + public function isUpload() { |
|
| 964 | 921 | return Mime::UPLOAD == $this->content_type; |
| 965 | 922 | } |
| 966 | 923 | |
| 967 | 924 | /** |
| 968 | 925 | * @return string |
| 969 | 926 | */ |
| 970 | - public function buildUserAgent() |
|
| 971 | - { |
|
| 927 | + public function buildUserAgent() { |
|
| 972 | 928 | $user_agent = 'User-Agent: Httpful/' . Httpful::VERSION . ' (cURL/'; |
| 973 | 929 | $curl = \curl_version(); |
| 974 | 930 | |
@@ -1009,8 +965,7 @@ discard block |
||
| 1009 | 965 | * @param string $curlopt |
| 1010 | 966 | * @param mixed $curloptval |
| 1011 | 967 | */ |
| 1012 | - public function addOnCurlOption($curlopt, $curloptval) |
|
| 1013 | - { |
|
| 968 | + public function addOnCurlOption($curlopt, $curloptval) { |
|
| 1014 | 969 | $this->additional_curl_opts[$curlopt] = $curloptval; |
| 1015 | 970 | return $this; |
| 1016 | 971 | } |
@@ -1030,14 +985,15 @@ discard block |
||
| 1030 | 985 | * @return string |
| 1031 | 986 | * @param mixed $payload |
| 1032 | 987 | */ |
| 1033 | - private function _serializePayload($payload) |
|
| 1034 | - { |
|
| 1035 | - if (empty($payload) || $this->serialize_payload_method === self::SERIALIZE_PAYLOAD_NEVER) |
|
| 1036 | - return $payload; |
|
| 988 | + private function _serializePayload($payload) { |
|
| 989 | + if (empty($payload) || $this->serialize_payload_method === self::SERIALIZE_PAYLOAD_NEVER) { |
|
| 990 | + return $payload; |
|
| 991 | + } |
|
| 1037 | 992 | |
| 1038 | 993 | // When we are in "smart" mode, don't serialize strings/scalars, assume they are already serialized |
| 1039 | - if ($this->serialize_payload_method === self::SERIALIZE_PAYLOAD_SMART && is_scalar($payload)) |
|
| 1040 | - return $payload; |
|
| 994 | + if ($this->serialize_payload_method === self::SERIALIZE_PAYLOAD_SMART && is_scalar($payload)) { |
|
| 995 | + return $payload; |
|
| 996 | + } |
|
| 1041 | 997 | |
| 1042 | 998 | // Use a custom serializer if one is registered for this mime type |
| 1043 | 999 | if (isset($this->payload_serializers['*']) || isset($this->payload_serializers[$this->content_type])) { |
@@ -1054,8 +1010,7 @@ discard block |
||
| 1054 | 1010 | * @param string $uri optional uri to use |
| 1055 | 1011 | * @param string $mime expected |
| 1056 | 1012 | */ |
| 1057 | - public static function get($uri, $mime = null) |
|
| 1058 | - { |
|
| 1013 | + public static function get($uri, $mime = null) { |
|
| 1059 | 1014 | return self::init(Http::GET)->uri($uri)->mime($mime); |
| 1060 | 1015 | } |
| 1061 | 1016 | |
@@ -1067,8 +1022,7 @@ discard block |
||
| 1067 | 1022 | * @param string $uri optional uri to use |
| 1068 | 1023 | * @param string $mime expected |
| 1069 | 1024 | */ |
| 1070 | - public static function getQuick($uri, $mime = null) |
|
| 1071 | - { |
|
| 1025 | + public static function getQuick($uri, $mime = null) { |
|
| 1072 | 1026 | return self::get($uri, $mime)->send(); |
| 1073 | 1027 | } |
| 1074 | 1028 | |
@@ -1079,8 +1033,7 @@ discard block |
||
| 1079 | 1033 | * @param string $payload data to send in body of request |
| 1080 | 1034 | * @param string $mime MIME to use for Content-Type |
| 1081 | 1035 | */ |
| 1082 | - public static function post($uri, $payload = null, $mime = null) |
|
| 1083 | - { |
|
| 1036 | + public static function post($uri, $payload = null, $mime = null) { |
|
| 1084 | 1037 | return self::init(Http::POST)->uri($uri)->body($payload, $mime); |
| 1085 | 1038 | } |
| 1086 | 1039 | |
@@ -1091,8 +1044,7 @@ discard block |
||
| 1091 | 1044 | * @param string $payload data to send in body of request |
| 1092 | 1045 | * @param string $mime MIME to use for Content-Type |
| 1093 | 1046 | */ |
| 1094 | - public static function put($uri, $payload = null, $mime = null) |
|
| 1095 | - { |
|
| 1047 | + public static function put($uri, $payload = null, $mime = null) { |
|
| 1096 | 1048 | return self::init(Http::PUT)->uri($uri)->body($payload, $mime); |
| 1097 | 1049 | } |
| 1098 | 1050 | |
@@ -1103,8 +1055,7 @@ discard block |
||
| 1103 | 1055 | * @param string $payload data to send in body of request |
| 1104 | 1056 | * @param string $mime MIME to use for Content-Type |
| 1105 | 1057 | */ |
| 1106 | - public static function patch($uri, $payload = null, $mime = null) |
|
| 1107 | - { |
|
| 1058 | + public static function patch($uri, $payload = null, $mime = null) { |
|
| 1108 | 1059 | return self::init(Http::PATCH)->uri($uri)->body($payload, $mime); |
| 1109 | 1060 | } |
| 1110 | 1061 | |
@@ -1113,8 +1064,7 @@ discard block |
||
| 1113 | 1064 | * @return Request |
| 1114 | 1065 | * @param string $uri optional uri to use |
| 1115 | 1066 | */ |
| 1116 | - public static function delete($uri, $mime = null) |
|
| 1117 | - { |
|
| 1067 | + public static function delete($uri, $mime = null) { |
|
| 1118 | 1068 | return self::init(Http::DELETE)->uri($uri)->mime($mime); |
| 1119 | 1069 | } |
| 1120 | 1070 | |
@@ -1123,8 +1073,7 @@ discard block |
||
| 1123 | 1073 | * @return Request |
| 1124 | 1074 | * @param string $uri optional uri to use |
| 1125 | 1075 | */ |
| 1126 | - public static function head($uri) |
|
| 1127 | - { |
|
| 1076 | + public static function head($uri) { |
|
| 1128 | 1077 | return self::init(Http::HEAD)->uri($uri); |
| 1129 | 1078 | } |
| 1130 | 1079 | |
@@ -1133,8 +1082,7 @@ discard block |
||
| 1133 | 1082 | * @return Request |
| 1134 | 1083 | * @param string $uri optional uri to use |
| 1135 | 1084 | */ |
| 1136 | - public static function options($uri) |
|
| 1137 | - { |
|
| 1085 | + public static function options($uri) { |
|
| 1138 | 1086 | return self::init(Http::OPTIONS)->uri($uri); |
| 1139 | 1087 | } |
| 1140 | 1088 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | $method = Http::GET, |
| 33 | 33 | $headers = array(), |
| 34 | 34 | $raw_headers = '', |
| 35 | - $strict_ssl = false, |
|
| 35 | + $strict_ssl = FALSE, |
|
| 36 | 36 | $content_type, |
| 37 | 37 | $expected_type, |
| 38 | 38 | $additional_curl_opts = array(), |
| 39 | - $auto_parse = true, |
|
| 39 | + $auto_parse = TRUE, |
|
| 40 | 40 | $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART, |
| 41 | 41 | $username, |
| 42 | 42 | $password, |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $payload, |
| 45 | 45 | $parse_callback, |
| 46 | 46 | $error_callback, |
| 47 | - $follow_redirects = false, |
|
| 47 | + $follow_redirects = FALSE, |
|
| 48 | 48 | $max_redirects = self::MAX_REDIRECTS_DEFAULT, |
| 49 | 49 | $payload_serializers = array(); |
| 50 | 50 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * for internal use. |
| 69 | 69 | * @param array $attrs hash of initial attribute values |
| 70 | 70 | */ |
| 71 | - private function __construct($attrs = null) |
|
| 71 | + private function __construct($attrs = NULL) |
|
| 72 | 72 | { |
| 73 | 73 | if (!is_array($attrs)) return; |
| 74 | 74 | foreach ($attrs as $attr => $value) { |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @return Request $this |
| 173 | 173 | * @param bool|int $follow follow or not to follow or maximal number of redirects |
| 174 | 174 | */ |
| 175 | - public function followRedirects($follow = true) |
|
| 175 | + public function followRedirects($follow = TRUE) |
|
| 176 | 176 | { |
| 177 | - $this->max_redirects = $follow === true ? self::MAX_REDIRECTS_DEFAULT : max(0, $follow); |
|
| 177 | + $this->max_redirects = $follow === TRUE ? self::MAX_REDIRECTS_DEFAULT : max(0, $follow); |
|
| 178 | 178 | $this->follow_redirects = (bool) $follow; |
| 179 | 179 | return $this; |
| 180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function doNotFollowRedirects() |
| 187 | 187 | { |
| 188 | - return $this->followRedirects(false); |
|
| 188 | + return $this->followRedirects(FALSE); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | $result = curl_exec($this->_ch); |
| 202 | 202 | |
| 203 | - if ($result === false) { |
|
| 203 | + if ($result === FALSE) { |
|
| 204 | 204 | if ($curlErrorNumber = curl_errno($this->_ch)) { |
| 205 | 205 | $curlErrorString = curl_error($this->_ch); |
| 206 | 206 | $this->_error($curlErrorString); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @param string $passphrase for client key |
| 304 | 304 | * @param string $encoding default PEM |
| 305 | 305 | */ |
| 306 | - public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM') |
|
| 306 | + public function clientSideCert($cert, $key, $passphrase = NULL, $encoding = 'PEM') |
|
| 307 | 307 | { |
| 308 | 308 | $this->client_cert = $cert; |
| 309 | 309 | $this->client_key = $key; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | return $this; |
| 314 | 314 | } |
| 315 | 315 | // @alias of basicAuth |
| 316 | - public function authenticateWithCert($cert, $key, $passphrase = null, $encoding = 'PEM') |
|
| 316 | + public function authenticateWithCert($cert, $key, $passphrase = NULL, $encoding = 'PEM') |
|
| 317 | 317 | { |
| 318 | 318 | return $this->clientSideCert($cert, $key, $passphrase, $encoding); |
| 319 | 319 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @param string $mimeType currently, sets the sends AND expects mime type although this |
| 326 | 326 | * behavior may change in the next minor release (as it is a potential breaking change). |
| 327 | 327 | */ |
| 328 | - public function body($payload, $mimeType = null) |
|
| 328 | + public function body($payload, $mimeType = NULL) |
|
| 329 | 329 | { |
| 330 | 330 | $this->mime($mimeType); |
| 331 | 331 | $this->payload = $payload; |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | public function withoutStrictSSL() |
| 443 | 443 | { |
| 444 | - return $this->strictSSL(false); |
|
| 444 | + return $this->strictSSL(FALSE); |
|
| 445 | 445 | } |
| 446 | 446 | public function withStrictSSL() |
| 447 | 447 | { |
| 448 | - return $this->strictSSL(true); |
|
| 448 | + return $this->strictSSL(TRUE); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * @param string $auth_username Authentication username. Default null |
| 458 | 458 | * @param string $auth_password Authentication password. Default null |
| 459 | 459 | */ |
| 460 | - public function useProxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null, $proxy_type = Proxy::HTTP) |
|
| 460 | + public function useProxy($proxy_host, $proxy_port = 80, $auth_type = NULL, $auth_username = NULL, $auth_password = NULL, $proxy_type = Proxy::HTTP) |
|
| 461 | 461 | { |
| 462 | 462 | $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}"); |
| 463 | 463 | $this->addOnCurlOption(CURLOPT_PROXYTYPE, $proxy_type); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | * @see Request::useProxy |
| 474 | 474 | * @return Request |
| 475 | 475 | */ |
| 476 | - public function useSocks4Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) |
|
| 476 | + public function useSocks4Proxy($proxy_host, $proxy_port = 80, $auth_type = NULL, $auth_username = NULL, $auth_password = NULL) |
|
| 477 | 477 | { |
| 478 | 478 | return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS4); |
| 479 | 479 | } |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * @see Request::useProxy |
| 484 | 484 | * @return Request |
| 485 | 485 | */ |
| 486 | - public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null) |
|
| 486 | + public function useSocks5Proxy($proxy_host, $proxy_port = 80, $auth_type = NULL, $auth_username = NULL, $auth_password = NULL) |
|
| 487 | 487 | { |
| 488 | 488 | return $this->useProxy($proxy_host, $proxy_port, $auth_type, $auth_username, $auth_password, Proxy::SOCKS5); |
| 489 | 489 | } |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * If not auto parsing, Response->body returns the body |
| 591 | 591 | * as a string. |
| 592 | 592 | */ |
| 593 | - public function autoParse($auto_parse = true) |
|
| 593 | + public function autoParse($auto_parse = TRUE) |
|
| 594 | 594 | { |
| 595 | 595 | $this->auto_parse = $auto_parse; |
| 596 | 596 | return $this; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | public function withoutAutoParsing() |
| 604 | 604 | { |
| 605 | - return $this->autoParse(false); |
|
| 605 | + return $this->autoParse(FALSE); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | public function withAutoParsing() |
| 613 | 613 | { |
| 614 | - return $this->autoParse(true); |
|
| 614 | + return $this->autoParse(TRUE); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /** |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @param string $method Http Method |
| 797 | 797 | * @param string $mime Mime Type to Use |
| 798 | 798 | */ |
| 799 | - public static function init($method = null, $mime = null) |
|
| 799 | + public static function init($method = NULL, $mime = NULL) |
|
| 800 | 800 | { |
| 801 | 801 | // Setup our handlers, can call it here as it's idempotent |
| 802 | 802 | Bootstrap::init(); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method); |
| 831 | 831 | if ($this->method === Http::HEAD) { |
| 832 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 832 | + curl_setopt($ch, CURLOPT_NOBODY, TRUE); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | if ($this->hasBasicAuth()) { |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | if ($this->follow_redirects) { |
| 864 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 864 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
| 865 | 865 | curl_setopt($ch, CURLOPT_MAXREDIRS, $this->max_redirects); |
| 866 | 866 | } |
| 867 | 867 | |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | //Support for value 1 removed in cURL 7.28.1 value 2 valid in all versions |
| 872 | 872 | if ($verifyValue > 0) $verifyValue++; |
| 873 | 873 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyValue); |
| 874 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 874 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
|
| 875 | 875 | |
| 876 | 876 | // https://github.com/nategood/httpful/issues/84 |
| 877 | 877 | // set Content-Length to the size of the payload if present |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
| 928 | 928 | |
| 929 | 929 | if ($this->_debug) { |
| 930 | - curl_setopt($ch, CURLOPT_VERBOSE, true); |
|
| 930 | + curl_setopt($ch, CURLOPT_VERBOSE, TRUE); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | curl_setopt($ch, CURLOPT_HEADER, 1); |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | * @param string $uri optional uri to use |
| 1055 | 1055 | * @param string $mime expected |
| 1056 | 1056 | */ |
| 1057 | - public static function get($uri, $mime = null) |
|
| 1057 | + public static function get($uri, $mime = NULL) |
|
| 1058 | 1058 | { |
| 1059 | 1059 | return self::init(Http::GET)->uri($uri)->mime($mime); |
| 1060 | 1060 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | * @param string $uri optional uri to use |
| 1068 | 1068 | * @param string $mime expected |
| 1069 | 1069 | */ |
| 1070 | - public static function getQuick($uri, $mime = null) |
|
| 1070 | + public static function getQuick($uri, $mime = NULL) |
|
| 1071 | 1071 | { |
| 1072 | 1072 | return self::get($uri, $mime)->send(); |
| 1073 | 1073 | } |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | * @param string $payload data to send in body of request |
| 1080 | 1080 | * @param string $mime MIME to use for Content-Type |
| 1081 | 1081 | */ |
| 1082 | - public static function post($uri, $payload = null, $mime = null) |
|
| 1082 | + public static function post($uri, $payload = NULL, $mime = NULL) |
|
| 1083 | 1083 | { |
| 1084 | 1084 | return self::init(Http::POST)->uri($uri)->body($payload, $mime); |
| 1085 | 1085 | } |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | * @param string $payload data to send in body of request |
| 1092 | 1092 | * @param string $mime MIME to use for Content-Type |
| 1093 | 1093 | */ |
| 1094 | - public static function put($uri, $payload = null, $mime = null) |
|
| 1094 | + public static function put($uri, $payload = NULL, $mime = NULL) |
|
| 1095 | 1095 | { |
| 1096 | 1096 | return self::init(Http::PUT)->uri($uri)->body($payload, $mime); |
| 1097 | 1097 | } |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | * @param string $payload data to send in body of request |
| 1104 | 1104 | * @param string $mime MIME to use for Content-Type |
| 1105 | 1105 | */ |
| 1106 | - public static function patch($uri, $payload = null, $mime = null) |
|
| 1106 | + public static function patch($uri, $payload = NULL, $mime = NULL) |
|
| 1107 | 1107 | { |
| 1108 | 1108 | return self::init(Http::PATCH)->uri($uri)->body($payload, $mime); |
| 1109 | 1109 | } |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | * @return Request |
| 1114 | 1114 | * @param string $uri optional uri to use |
| 1115 | 1115 | */ |
| 1116 | - public static function delete($uri, $mime = null) |
|
| 1116 | + public static function delete($uri, $mime = NULL) |
|
| 1117 | 1117 | { |
| 1118 | 1118 | return self::init(Http::DELETE)->uri($uri)->mime($mime); |
| 1119 | 1119 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | switch ($piVars['action']) { |
| 76 | 76 | case 'mets': |
| 77 | - $path = rtrim('http://' . $fedoraHost,"/").'/fedora/objects/'.$piVars['qid'].'/methods/qucosa:SDef/getMETSDissemination?supplement=yes'; |
|
| 77 | + $path = rtrim('http://' . $fedoraHost, "/") . '/fedora/objects/' . $piVars['qid'] . '/methods/qucosa:SDef/getMETSDissemination?supplement=yes'; |
|
| 78 | 78 | break; |
| 79 | 79 | |
| 80 | 80 | case 'preview': |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $qid = $piVars['qid']; |
| 139 | 139 | $source = explode(':', $qid); |
| 140 | - if($source[0] == 'qucosa') { |
|
| 140 | + if ($source[0] == 'qucosa') { |
|
| 141 | 141 | |
| 142 | - $path = rtrim('http://' . $fedoraHost,"/").'/fedora/objects/'.$piVars['qid'].'/methods/qucosa:SDef/getMETSDissemination?supplement=yes'; |
|
| 142 | + $path = rtrim('http://' . $fedoraHost, "/") . '/fedora/objects/' . $piVars['qid'] . '/methods/qucosa:SDef/getMETSDissemination?supplement=yes'; |
|
| 143 | 143 | $metsXml = str_replace('&', '&', file_get_contents($path)); |
| 144 | 144 | $dataCiteXml = \EWW\Dpf\Helper\DataCiteXml::convertFromMetsXml($metsXml); |
| 145 | 145 | |
| 146 | - } elseif($document = $this->documentRepository->findByUid($piVars['qid'])) { |
|
| 146 | + } elseif ($document = $this->documentRepository->findByUid($piVars['qid'])) { |
|
| 147 | 147 | |
| 148 | 148 | $metsXml = str_replace('&', '&', $this->buildMetsXml($document)); |
| 149 | 149 | $dataCiteXml = \EWW\Dpf\Helper\DataCiteXml::convertFromMetsXml($metsXml); |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * GetFileController |
| 48 | 48 | */ |
| 49 | -class GetFileController extends \EWW\Dpf\Controller\AbstractController |
|
| 50 | -{ |
|
| 49 | +class GetFileController extends \EWW\Dpf\Controller\AbstractController { |
|
| 51 | 50 | |
| 52 | 51 | /** |
| 53 | 52 | * documentRepository |
@@ -65,8 +64,7 @@ discard block |
||
| 65 | 64 | */ |
| 66 | 65 | protected $clientConfigurationManager; |
| 67 | 66 | |
| 68 | - public function attachmentAction() |
|
| 69 | - { |
|
| 67 | + public function attachmentAction() { |
|
| 70 | 68 | |
| 71 | 69 | $piVars = GeneralUtility::_GP('tx_dpf'); // get GET params from powermail |
| 72 | 70 | |
@@ -232,8 +230,7 @@ discard block |
||
| 232 | 230 | |
| 233 | 231 | } |
| 234 | 232 | |
| 235 | - private static function sanitizeFilename($filename) |
|
| 236 | - { |
|
| 233 | + private static function sanitizeFilename($filename) { |
|
| 237 | 234 | // remove anything which isn't a word, whitespace, number or any of the following caracters -_~,;[](). |
| 238 | 235 | $filename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename); |
| 239 | 236 | // turn diacritical characters to ASCII |
@@ -245,8 +242,7 @@ discard block |
||
| 245 | 242 | return $filename; |
| 246 | 243 | } |
| 247 | 244 | |
| 248 | - private function buildMetsXml($document) |
|
| 249 | - { |
|
| 245 | + private function buildMetsXml($document) { |
|
| 250 | 246 | |
| 251 | 247 | $exporter = new \EWW\Dpf\Services\MetsExporter(); |
| 252 | 248 | $fileData = $document->getCurrentFileData(); |
@@ -179,20 +179,20 @@ |
||
| 179 | 179 | return 'Error while fetching headers'; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $contentDispFlag = false; |
|
| 183 | - $contentTypeFlag = false; |
|
| 182 | + $contentDispFlag = FALSE; |
|
| 183 | + $contentTypeFlag = FALSE; |
|
| 184 | 184 | |
| 185 | 185 | foreach ($headers as $value) { |
| 186 | 186 | |
| 187 | 187 | if (FALSE !== stripos($value, 'Content-Disposition')) { |
| 188 | 188 | header($value); |
| 189 | - $contentDispFlag = true; |
|
| 189 | + $contentDispFlag = TRUE; |
|
| 190 | 190 | continue; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if (FALSE !== stripos($value, 'Content-Type')) { |
| 194 | 194 | header($value); |
| 195 | - $contentTypeFlag = true; |
|
| 195 | + $contentTypeFlag = TRUE; |
|
| 196 | 196 | continue; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -106,6 +106,6 @@ |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function getProcessNumberString() { |
| 109 | - return strtoupper($this->getOwnerId()).'-'. $this->getYear().'-'.$this->getCounter(); |
|
| 109 | + return strtoupper($this->getOwnerId()) . '-' . $this->getYear() . '-' . $this->getCounter(); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | \ No newline at end of file |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return string $ownerId |
| 49 | 49 | */ |
| 50 | - public function getOwnerId() |
|
| 51 | - { |
|
| 50 | + public function getOwnerId() { |
|
| 52 | 51 | return $this->ownerId; |
| 53 | 52 | } |
| 54 | 53 | |
@@ -58,8 +57,7 @@ discard block |
||
| 58 | 57 | * @param string $ownerId |
| 59 | 58 | * @return void |
| 60 | 59 | */ |
| 61 | - public function setOwnerId($ownerId) |
|
| 62 | - { |
|
| 60 | + public function setOwnerId($ownerId) { |
|
| 63 | 61 | $this->ownerId = $ownerId; |
| 64 | 62 | } |
| 65 | 63 | |
@@ -68,8 +66,7 @@ discard block |
||
| 68 | 66 | * |
| 69 | 67 | * @return int $year |
| 70 | 68 | */ |
| 71 | - public function getYear() |
|
| 72 | - { |
|
| 69 | + public function getYear() { |
|
| 73 | 70 | return $this->year; |
| 74 | 71 | } |
| 75 | 72 | |
@@ -79,8 +76,7 @@ discard block |
||
| 79 | 76 | * @param int $year |
| 80 | 77 | * @return void |
| 81 | 78 | */ |
| 82 | - public function setYear($year) |
|
| 83 | - { |
|
| 79 | + public function setYear($year) { |
|
| 84 | 80 | $this->year = $year; |
| 85 | 81 | } |
| 86 | 82 | |
@@ -89,8 +85,7 @@ discard block |
||
| 89 | 85 | * |
| 90 | 86 | * @return int $counter |
| 91 | 87 | */ |
| 92 | - public function getCounter() |
|
| 93 | - { |
|
| 88 | + public function getCounter() { |
|
| 94 | 89 | return $this->counter; |
| 95 | 90 | } |
| 96 | 91 | |
@@ -100,8 +95,7 @@ discard block |
||
| 100 | 95 | * @param int $counter |
| 101 | 96 | * @return void |
| 102 | 97 | */ |
| 103 | - public function setCounter($counter) |
|
| 104 | - { |
|
| 98 | + public function setCounter($counter) { |
|
| 105 | 99 | $this->counter = $counter; |
| 106 | 100 | } |
| 107 | 101 | |
@@ -107,7 +107,6 @@ |
||
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Get PDF document list |
| 110 | - |
|
| 111 | 110 | * @return array of attachments |
| 112 | 111 | */ |
| 113 | 112 | protected function getAttachments() |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | foreach ($attachments as $id => $file) { |
| 85 | 85 | |
| 86 | - $conf = array( |
|
| 86 | + $conf = array ( |
|
| 87 | 87 | 'useCacheHash' => 0, |
| 88 | 88 | 'parameter' => $this->conf['apiPid'] . ' - piwik_download', |
| 89 | 89 | 'additionalParams' => '&tx_dpf[qid]=' . $this->doc->recordId . '&tx_dpf[action]=attachment' . '&tx_dpf[attachment]=' . $file['ID'], |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | if (!is_array($files)) { |
| 122 | 122 | |
| 123 | - return array(); |
|
| 123 | + return array (); |
|
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | foreach ($files as $key => $file) { |
| 128 | 128 | |
| 129 | - $singleFile = array(); |
|
| 129 | + $singleFile = array (); |
|
| 130 | 130 | |
| 131 | 131 | foreach ($file->attributes('mext', 1) as $attribute => $value) { |
| 132 | 132 | |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | * @subpackage tx_dpf |
| 23 | 23 | * @access public |
| 24 | 24 | */ |
| 25 | -class DownloadTool extends \tx_dlf_plugin |
|
| 26 | -{ |
|
| 25 | +class DownloadTool extends \tx_dlf_plugin { |
|
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * The main method of the PlugIn |
@@ -35,8 +34,7 @@ discard block |
||
| 35 | 34 | * |
| 36 | 35 | * @return string The content that is displayed on the website |
| 37 | 36 | */ |
| 38 | - public function main($content, $conf) |
|
| 39 | - { |
|
| 37 | + public function main($content, $conf) { |
|
| 40 | 38 | |
| 41 | 39 | $this->init($conf); |
| 42 | 40 | |
@@ -110,8 +108,7 @@ discard block |
||
| 110 | 108 | |
| 111 | 109 | * @return array of attachments |
| 112 | 110 | */ |
| 113 | - protected function getAttachments() |
|
| 114 | - { |
|
| 111 | + protected function getAttachments() { |
|
| 115 | 112 | |
| 116 | 113 | // Get pdf documents |
| 117 | 114 | $xPath = 'mets:fileSec/mets:fileGrp[@USE="' . $this->conf['fileGrpDownload'] . '"]/mets:file'; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if (is_array($dpfTSconfig['settings.'])) { |
| 48 | 48 | |
| 49 | - \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($dpfTSconfig['settings.'], $this->conf, true, false); |
|
| 49 | + \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($dpfTSconfig['settings.'], $this->conf, TRUE, FALSE); |
|
| 50 | 50 | $this->conf = $dpfTSconfig['settings.']; |
| 51 | 51 | |
| 52 | 52 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | // Load current document. |
| 55 | 55 | $this->loadDocument(); |
| 56 | 56 | |
| 57 | - if ($this->doc === null || empty($this->conf['fileGrpDownload'])) { |
|
| 57 | + if ($this->doc === NULL || empty($this->conf['fileGrpDownload'])) { |
|
| 58 | 58 | |
| 59 | 59 | // Quit without doing anything if required variables are not set. |
| 60 | 60 | return $content; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | 'useCacheHash' => 0, |
| 88 | 88 | 'parameter' => $this->conf['apiPid'] . ' - piwik_download', |
| 89 | 89 | 'additionalParams' => '&tx_dpf[qid]=' . $this->doc->recordId . '&tx_dpf[action]=attachment' . '&tx_dpf[attachment]=' . $file['ID'], |
| 90 | - 'forceAbsoluteUrl' => true, |
|
| 90 | + 'forceAbsoluteUrl' => TRUE, |
|
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | 93 | $title = $file['LABEL'] ? $file['LABEL'] : $file['ID']; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - return $this->cObj->substituteSubpart($this->template, '###DOWNLOADS###', $content, true); |
|
| 104 | + return $this->cObj->substituteSubpart($this->template, '###DOWNLOADS###', $content, TRUE); |
|
| 105 | 105 | |
| 106 | 106 | } |
| 107 | 107 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | class ClientConfigurationManager |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 20 | + /** |
|
| 21 | 21 | * objectManager |
| 22 | 22 | * |
| 23 | 23 | * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function __construct() |
| 59 | 59 | { |
| 60 | - $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\Object\\ObjectManager'); |
|
| 60 | + $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\Object\\ObjectManager'); |
|
| 61 | 61 | $clientRepository = $objectManager->get("EWW\\Dpf\\Domain\\Repository\\ClientRepository"); |
| 62 | 62 | |
| 63 | - if (TYPO3_MODE === 'BE') |
|
| 64 | - { |
|
| 63 | + if (TYPO3_MODE === 'BE') |
|
| 64 | + { |
|
| 65 | 65 | $selectedPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); |
| 66 | 66 | if ($selectedPageId) |
| 67 | 67 | { |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | $this->settings = $settings; //['settings']; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - } |
|
| 76 | - else |
|
| 77 | - { |
|
| 75 | + } |
|
| 76 | + else |
|
| 77 | + { |
|
| 78 | 78 | $this->client = $clientRepository->findAll()->current(); |
| 79 | 79 | |
| 80 | - $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); |
|
| 81 | - $this->settings = $configurationManager->getConfiguration( |
|
| 82 | - \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS |
|
| 83 | - ); |
|
| 80 | + $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); |
|
| 81 | + $this->settings = $configurationManager->getConfiguration( |
|
| 82 | + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS |
|
| 83 | + ); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -111,57 +111,57 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | public function getSwordHost() |
| 113 | 113 | { |
| 114 | - return $this->getSetting("swordHost","swordHost"); |
|
| 114 | + return $this->getSetting("swordHost","swordHost"); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function getSwordUser() |
|
| 117 | + public function getSwordUser() |
|
| 118 | 118 | { |
| 119 | - return $this->getSetting("swordUser","swordUser"); |
|
| 119 | + return $this->getSetting("swordUser","swordUser"); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function getSwordPassword() |
|
| 122 | + public function getSwordPassword() |
|
| 123 | 123 | { |
| 124 | - return $this->getSetting("swordPassword","swordPassword"); |
|
| 124 | + return $this->getSetting("swordPassword","swordPassword"); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public function getSwordCollectionNamespace() |
|
| 127 | + public function getSwordCollectionNamespace() |
|
| 128 | 128 | { |
| 129 | - return $this->getSetting("swordCollectionNamespace","swordCollectionNamespace"); |
|
| 129 | + return $this->getSetting("swordCollectionNamespace","swordCollectionNamespace"); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function getFedoraHost() |
|
| 132 | + public function getFedoraHost() |
|
| 133 | 133 | { |
| 134 | - return $this->getSetting("fedoraHost","fedoraHost"); |
|
| 134 | + return $this->getSetting("fedoraHost","fedoraHost"); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function getFedoraUser() |
|
| 137 | + public function getFedoraUser() |
|
| 138 | 138 | { |
| 139 | - return $this->getSetting("fedoraUser","fedoraUser"); |
|
| 139 | + return $this->getSetting("fedoraUser","fedoraUser"); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function getFedoraPassword() |
|
| 142 | + public function getFedoraPassword() |
|
| 143 | 143 | { |
| 144 | - return $this->getSetting("fedoraPassword","fedoraPassword"); |
|
| 144 | + return $this->getSetting("fedoraPassword","fedoraPassword"); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function getElasticSearchHost() |
|
| 147 | + public function getElasticSearchHost() |
|
| 148 | 148 | { |
| 149 | - return $this->getSetting("elasticSearchHost","elasticSearchHost"); |
|
| 149 | + return $this->getSetting("elasticSearchHost","elasticSearchHost"); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function getElasticSearchPort() |
|
| 152 | + public function getElasticSearchPort() |
|
| 153 | 153 | { |
| 154 | - return $this->getSetting("elasticSearchPort","elasticSearchPort"); |
|
| 154 | + return $this->getSetting("elasticSearchPort","elasticSearchPort"); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function getUploadDirectory() |
|
| 157 | + public function getUploadDirectory() |
|
| 158 | 158 | { |
| 159 | - return $this->getSetting("uploadDirectory","uploadDirectory"); |
|
| 159 | + return $this->getSetting("uploadDirectory","uploadDirectory"); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function getUploadDomain() |
|
| 162 | + public function getUploadDomain() |
|
| 163 | 163 | { |
| 164 | - return $this->getSetting("uploadDomain","uploadDomain"); |
|
| 164 | + return $this->getSetting("uploadDomain","uploadDomain"); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @var array |
| 40 | 40 | */ |
| 41 | - protected $settings = array(); |
|
| 41 | + protected $settings = array (); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @var array |
| 55 | 55 | */ |
| 56 | - protected $extensionConfiguration = array(); |
|
| 56 | + protected $extensionConfiguration = array (); |
|
| 57 | 57 | |
| 58 | 58 | public function __construct() |
| 59 | 59 | { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->client = $clientRepository->findAll()->current(); |
| 69 | 69 | |
| 70 | 70 | $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager'); |
| 71 | - $settings = $configurationManager->getConfiguration(NULL,NULL); |
|
| 71 | + $settings = $configurationManager->getConfiguration(NULL, NULL); |
|
| 72 | 72 | $this->settings = $settings; //['settings']; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $setting = NULL; |
| 94 | 94 | if ($this->client) |
| 95 | 95 | { |
| 96 | - $setting = trim($this->client->{"get".ucfirst($settingName)}()); |
|
| 96 | + $setting = trim($this->client->{"get" . ucfirst($settingName)}()); |
|
| 97 | 97 | if (!(is_string($setting) && $setting != "") && $extConfig) |
| 98 | 98 | { |
| 99 | 99 | $setting = trim($this->extensionConfiguration[$extConfig]); |
@@ -111,57 +111,57 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | public function getSwordHost() |
| 113 | 113 | { |
| 114 | - return $this->getSetting("swordHost","swordHost"); |
|
| 114 | + return $this->getSetting("swordHost", "swordHost"); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function getSwordUser() |
| 118 | 118 | { |
| 119 | - return $this->getSetting("swordUser","swordUser"); |
|
| 119 | + return $this->getSetting("swordUser", "swordUser"); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function getSwordPassword() |
| 123 | 123 | { |
| 124 | - return $this->getSetting("swordPassword","swordPassword"); |
|
| 124 | + return $this->getSetting("swordPassword", "swordPassword"); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public function getSwordCollectionNamespace() |
| 128 | 128 | { |
| 129 | - return $this->getSetting("swordCollectionNamespace","swordCollectionNamespace"); |
|
| 129 | + return $this->getSetting("swordCollectionNamespace", "swordCollectionNamespace"); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function getFedoraHost() |
| 133 | 133 | { |
| 134 | - return $this->getSetting("fedoraHost","fedoraHost"); |
|
| 134 | + return $this->getSetting("fedoraHost", "fedoraHost"); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function getFedoraUser() |
| 138 | 138 | { |
| 139 | - return $this->getSetting("fedoraUser","fedoraUser"); |
|
| 139 | + return $this->getSetting("fedoraUser", "fedoraUser"); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function getFedoraPassword() |
| 143 | 143 | { |
| 144 | - return $this->getSetting("fedoraPassword","fedoraPassword"); |
|
| 144 | + return $this->getSetting("fedoraPassword", "fedoraPassword"); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function getElasticSearchHost() |
| 148 | 148 | { |
| 149 | - return $this->getSetting("elasticSearchHost","elasticSearchHost"); |
|
| 149 | + return $this->getSetting("elasticSearchHost", "elasticSearchHost"); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function getElasticSearchPort() |
| 153 | 153 | { |
| 154 | - return $this->getSetting("elasticSearchPort","elasticSearchPort"); |
|
| 154 | + return $this->getSetting("elasticSearchPort", "elasticSearchPort"); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function getUploadDirectory() |
| 158 | 158 | { |
| 159 | - return $this->getSetting("uploadDirectory","uploadDirectory"); |
|
| 159 | + return $this->getSetting("uploadDirectory", "uploadDirectory"); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public function getUploadDomain() |
| 163 | 163 | { |
| 164 | - return $this->getSetting("uploadDomain","uploadDomain"); |
|
| 164 | + return $this->getSetting("uploadDomain", "uploadDomain"); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | } |
@@ -14,8 +14,7 @@ discard block |
||
| 14 | 14 | * The TYPO3 project - inspiring people to share! |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -class ClientConfigurationManager |
|
| 18 | -{ |
|
| 17 | +class ClientConfigurationManager { |
|
| 19 | 18 | |
| 20 | 19 | /** |
| 21 | 20 | * objectManager |
@@ -55,16 +54,13 @@ discard block |
||
| 55 | 54 | */ |
| 56 | 55 | protected $extensionConfiguration = array(); |
| 57 | 56 | |
| 58 | - public function __construct() |
|
| 59 | - { |
|
| 57 | + public function __construct() { |
|
| 60 | 58 | $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\Object\\ObjectManager'); |
| 61 | 59 | $clientRepository = $objectManager->get("EWW\\Dpf\\Domain\\Repository\\ClientRepository"); |
| 62 | 60 | |
| 63 | - if (TYPO3_MODE === 'BE') |
|
| 64 | - { |
|
| 61 | + if (TYPO3_MODE === 'BE') { |
|
| 65 | 62 | $selectedPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); |
| 66 | - if ($selectedPageId) |
|
| 67 | - { |
|
| 63 | + if ($selectedPageId) { |
|
| 68 | 64 | $this->client = $clientRepository->findAll()->current(); |
| 69 | 65 | |
| 70 | 66 | $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager'); |
@@ -72,9 +68,7 @@ discard block |
||
| 72 | 68 | $this->settings = $settings; //['settings']; |
| 73 | 69 | } |
| 74 | 70 | |
| 75 | - } |
|
| 76 | - else |
|
| 77 | - { |
|
| 71 | + } else { |
|
| 78 | 72 | $this->client = $clientRepository->findAll()->current(); |
| 79 | 73 | |
| 80 | 74 | $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); |
@@ -88,14 +82,11 @@ discard block |
||
| 88 | 82 | } |
| 89 | 83 | |
| 90 | 84 | |
| 91 | - public function getSetting($settingName, $extConfig = NULL) |
|
| 92 | - { |
|
| 85 | + public function getSetting($settingName, $extConfig = NULL) { |
|
| 93 | 86 | $setting = NULL; |
| 94 | - if ($this->client) |
|
| 95 | - { |
|
| 87 | + if ($this->client) { |
|
| 96 | 88 | $setting = trim($this->client->{"get".ucfirst($settingName)}()); |
| 97 | - if (!(is_string($setting) && $setting != "") && $extConfig) |
|
| 98 | - { |
|
| 89 | + if (!(is_string($setting) && $setting != "") && $extConfig) { |
|
| 99 | 90 | $setting = trim($this->extensionConfiguration[$extConfig]); |
| 100 | 91 | } |
| 101 | 92 | } |
@@ -104,63 +95,51 @@ discard block |
||
| 104 | 95 | } |
| 105 | 96 | |
| 106 | 97 | |
| 107 | - public function getOwnerId() |
|
| 108 | - { |
|
| 98 | + public function getOwnerId() { |
|
| 109 | 99 | return $this->getSetting("ownerId"); |
| 110 | 100 | } |
| 111 | 101 | |
| 112 | - public function getSwordHost() |
|
| 113 | - { |
|
| 102 | + public function getSwordHost() { |
|
| 114 | 103 | return $this->getSetting("swordHost","swordHost"); |
| 115 | 104 | } |
| 116 | 105 | |
| 117 | - public function getSwordUser() |
|
| 118 | - { |
|
| 106 | + public function getSwordUser() { |
|
| 119 | 107 | return $this->getSetting("swordUser","swordUser"); |
| 120 | 108 | } |
| 121 | 109 | |
| 122 | - public function getSwordPassword() |
|
| 123 | - { |
|
| 110 | + public function getSwordPassword() { |
|
| 124 | 111 | return $this->getSetting("swordPassword","swordPassword"); |
| 125 | 112 | } |
| 126 | 113 | |
| 127 | - public function getSwordCollectionNamespace() |
|
| 128 | - { |
|
| 114 | + public function getSwordCollectionNamespace() { |
|
| 129 | 115 | return $this->getSetting("swordCollectionNamespace","swordCollectionNamespace"); |
| 130 | 116 | } |
| 131 | 117 | |
| 132 | - public function getFedoraHost() |
|
| 133 | - { |
|
| 118 | + public function getFedoraHost() { |
|
| 134 | 119 | return $this->getSetting("fedoraHost","fedoraHost"); |
| 135 | 120 | } |
| 136 | 121 | |
| 137 | - public function getFedoraUser() |
|
| 138 | - { |
|
| 122 | + public function getFedoraUser() { |
|
| 139 | 123 | return $this->getSetting("fedoraUser","fedoraUser"); |
| 140 | 124 | } |
| 141 | 125 | |
| 142 | - public function getFedoraPassword() |
|
| 143 | - { |
|
| 126 | + public function getFedoraPassword() { |
|
| 144 | 127 | return $this->getSetting("fedoraPassword","fedoraPassword"); |
| 145 | 128 | } |
| 146 | 129 | |
| 147 | - public function getElasticSearchHost() |
|
| 148 | - { |
|
| 130 | + public function getElasticSearchHost() { |
|
| 149 | 131 | return $this->getSetting("elasticSearchHost","elasticSearchHost"); |
| 150 | 132 | } |
| 151 | 133 | |
| 152 | - public function getElasticSearchPort() |
|
| 153 | - { |
|
| 134 | + public function getElasticSearchPort() { |
|
| 154 | 135 | return $this->getSetting("elasticSearchPort","elasticSearchPort"); |
| 155 | 136 | } |
| 156 | 137 | |
| 157 | - public function getUploadDirectory() |
|
| 158 | - { |
|
| 138 | + public function getUploadDirectory() { |
|
| 159 | 139 | return $this->getSetting("uploadDirectory","uploadDirectory"); |
| 160 | 140 | } |
| 161 | 141 | |
| 162 | - public function getUploadDomain() |
|
| 163 | - { |
|
| 142 | + public function getUploadDomain() { |
|
| 164 | 143 | return $this->getSetting("uploadDomain","uploadDomain"); |
| 165 | 144 | } |
| 166 | 145 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return Lexer::extend($this->comment(), [ |
| 20 | 20 | 'block' => [ |
| 21 | 21 | Lexer::MATCH => '[{]', |
| 22 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 22 | + Lexer::CALL => function($in, $out, $token) { |
|
| 23 | 23 | $out->startToken('type structure'); |
| 24 | 24 | |
| 25 | 25 | $begin = $token; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | 'predicate' => [ |
| 43 | 43 | Lexer::MATCH => '\[', |
| 44 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 44 | + Lexer::CALL => function($in, $out, $token) { |
|
| 45 | 45 | $out->startToken('predicate'); |
| 46 | 46 | |
| 47 | 47 | $begin = $token; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | 'selector' => [ |
| 70 | 70 | Lexer::MATCH => '([.:#]|[:]{2})[a-z0-9_-]+', |
| 71 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 71 | + Lexer::CALL => function($in, $out, $token) { |
|
| 72 | 72 | Lexer::choose($in, $out, $token, [ |
| 73 | 73 | [ |
| 74 | 74 | Lexer::MATCH => '%^[.]%i', |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | 'method' => [ |
| 129 | 129 | Lexer::MATCH => '[a-z0-9_-]+\s*(?=[(])', |
| 130 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 130 | + Lexer::CALL => function($in, $out, $token) { |
|
| 131 | 131 | $begin = $token; |
| 132 | 132 | $out->writeToken($begin, 'word method'); |
| 133 | 133 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return [ |
| 157 | 157 | 'comment' => [ |
| 158 | 158 | Lexer::MATCH => '/[*].*?[*]/', |
| 159 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 159 | + Lexer::CALL => function($in, $out, $token) { |
|
| 160 | 160 | $out->startToken('comment block'); |
| 161 | 161 | |
| 162 | 162 | $in = new Input(); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | 'value' => [ |
| 211 | 211 | Lexer::MATCH => ':', |
| 212 | - Lexer::CALL => function ($in, $out, $token) { |
|
| 212 | + Lexer::CALL => function($in, $out, $token) { |
|
| 213 | 213 | $begin = $token; |
| 214 | 214 | $out->writeRaw($begin); |
| 215 | 215 | |
@@ -12,10 +12,8 @@ discard block |
||
| 12 | 12 | use nbsp\bitter\Input; |
| 13 | 13 | use nbsp\bitter\Lexer; |
| 14 | 14 | |
| 15 | -trait CSS |
|
| 16 | -{ |
|
| 17 | - public function tokens() |
|
| 18 | - { |
|
| 15 | +trait CSS { |
|
| 16 | + public function tokens() { |
|
| 19 | 17 | return Lexer::extend($this->comment(), [ |
| 20 | 18 | 'block' => [ |
| 21 | 19 | Lexer::MATCH => '[{]', |
@@ -102,8 +100,7 @@ discard block |
||
| 102 | 100 | * |
| 103 | 101 | * @return array |
| 104 | 102 | */ |
| 105 | - public function common() |
|
| 106 | - { |
|
| 103 | + public function common() { |
|
| 107 | 104 | return Lexer::extend($this->comment(), [ |
| 108 | 105 | 'colour' => [ |
| 109 | 106 | Lexer::MATCH => '[#]([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b', |
@@ -151,8 +148,7 @@ discard block |
||
| 151 | 148 | * |
| 152 | 149 | * @return array |
| 153 | 150 | */ |
| 154 | - public function comment() |
|
| 155 | - { |
|
| 151 | + public function comment() { |
|
| 156 | 152 | return [ |
| 157 | 153 | 'comment' => [ |
| 158 | 154 | Lexer::MATCH => '/[*].*?[*]/', |
@@ -194,8 +190,7 @@ discard block |
||
| 194 | 190 | ]; |
| 195 | 191 | } |
| 196 | 192 | |
| 197 | - public function block() |
|
| 198 | - { |
|
| 193 | + public function block() { |
|
| 199 | 194 | return Lexer::extend($this->comment(), [ |
| 200 | 195 | 'end' => [ |
| 201 | 196 | Lexer::MATCH => '[}]', |
@@ -228,8 +223,7 @@ discard block |
||
| 228 | 223 | ]); |
| 229 | 224 | } |
| 230 | 225 | |
| 231 | - public function method() |
|
| 232 | - { |
|
| 226 | + public function method() { |
|
| 233 | 227 | return Lexer::extend($this->common(), [ |
| 234 | 228 | 'end' => [ |
| 235 | 229 | Lexer::MATCH => '[)]', |
@@ -238,8 +232,7 @@ discard block |
||
| 238 | 232 | ]); |
| 239 | 233 | } |
| 240 | 234 | |
| 241 | - public function value() |
|
| 242 | - { |
|
| 235 | + public function value() { |
|
| 243 | 236 | return Lexer::extend($this->common(), [ |
| 244 | 237 | 'end' => [ |
| 245 | 238 | Lexer::MATCH => ';', |