Skip to content

Commit 264b7bc

Browse files
authored
Merge pull request #14 from bilfeldt/analysis-0gLArw
Apply fixes from StyleCI
2 parents 49010da + 3374123 commit 264b7bc

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

src/MessageAccessor.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class MessageAccessor
1818
private string $replace;
1919

2020
public function __construct(
21-
array $values = [],
22-
array $queryFilters = [],
23-
array $headersFilters = [],
24-
array $jsonFilers = [],
21+
array $values = [],
22+
array $queryFilters = [],
23+
array $headersFilters = [],
24+
array $jsonFilers = [],
2525
string $replace = '********'
26-
){
26+
) {
2727
$this->values = $values;
2828
$this->queryFilters = $queryFilters;
2929
$this->headersFilters = $headersFilters;
@@ -49,16 +49,16 @@ public function getBase(RequestInterface $request): string
4949

5050
$base = '';
5151
if ($uri->getScheme()) {
52-
$base .= $uri->getScheme() . '://';
52+
$base .= $uri->getScheme().'://';
5353
}
5454
if ($uri->getUserInfo()) {
55-
$base .= $uri->getUserInfo() . '@';
55+
$base .= $uri->getUserInfo().'@';
5656
}
5757
if ($uri->getHost()) {
5858
$base .= $uri->getHost();
5959
}
6060
if ($uri->getPort()) {
61-
$base .= ':' . $uri->getPort();
61+
$base .= ':'.$uri->getPort();
6262
}
6363

6464
return $base;
@@ -87,7 +87,9 @@ public function getHeaders(MessageInterface $message): array
8787
* Determine if the request is JSON.
8888
*
8989
* @see vendor/laravel/framework/src/Illuminate/Http/Client/Request.php
90+
*
9091
* @param MessageInterface $message
92+
*
9193
* @return bool
9294
*/
9395
public function isJson(MessageInterface $message): bool
@@ -112,7 +114,7 @@ public function getContent(MessageInterface $message): string
112114
$body = json_encode($this->getJson($message));
113115
} else {
114116
$body = $message->getBody()->__toString();
115-
foreach($this->values as $value) {
117+
foreach ($this->values as $value) {
116118
$body = str_replace($value, $this->replace, $body);
117119
}
118120
}
@@ -139,9 +141,9 @@ protected function replaceParameters(array $array, array $parameters, array $val
139141
}
140142
}
141143

142-
array_walk_recursive( $array, function (&$item) use ($values, $replace, $strict) {
144+
array_walk_recursive($array, function (&$item) use ($values, $replace, $strict) {
143145
foreach ($values as $value) {
144-
if (! $strict && str_contains($item, $value)) {
146+
if (!$strict && str_contains($item, $value)) {
145147
$item = str_replace($value, $replace, $item);
146148
} elseif ($strict && $value === $item) {
147149
$item = $replace;

tests/MessageAccessorTest.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ public function setUp(): void
3030
'POST',
3131
'https://user:[email protected]:9000/some-path/secret/should-not-be-removed?test=true&search=foo&filter[field1]=A&filter[field2]=B#anchor',
3232
[
33-
'Accept' => 'application/json',
34-
'Content-Type' => 'application/json',
33+
'Accept' => 'application/json',
34+
'Content-Type' => 'application/json',
3535
'Authorization' => 'Bearer 1234567890',
3636
],
3737
json_encode([
3838
'data' => [
3939
'foo' => 'bar',
4040
'baz' => [
4141
[
42-
'field_1' => 'value1',
43-
'field_2' => 'value2',
42+
'field_1' => 'value1',
43+
'field_2' => 'value2',
4444
'password' => '123456',
45-
'secret' => 'this is not for everyone',
46-
]
47-
]
45+
'secret' => 'this is not for everyone',
46+
],
47+
],
4848
],
4949
])
5050
);
@@ -66,8 +66,10 @@ public function test_get_uri()
6666

6767
public function test_get_base()
6868
{
69-
$this->assertEquals('https://user:********@********.example.com:9000',
70-
urldecode($this->messageAccessor->getBase($this->request)));
69+
$this->assertEquals(
70+
'https://user:********@********.example.com:9000',
71+
urldecode($this->messageAccessor->getBase($this->request))
72+
);
7173
}
7274

7375
public function test_get_query()
@@ -76,7 +78,7 @@ public function test_get_query()
7678

7779
$this->assertIsArray($query);
7880
$this->assertEquals([
79-
'test' => 'true',
81+
'test' => 'true',
8082
'search' => '********',
8183
'filter' => [
8284
'field1' => 'A',
@@ -91,10 +93,10 @@ public function test_get_headers()
9193

9294
$this->assertIsArray($headers);
9395
$this->assertEquals([
94-
'Accept' => ['application/json'],
95-
'Content-Type' => ['application/json'],
96+
'Accept' => ['application/json'],
97+
'Content-Type' => ['application/json'],
9698
'Authorization' => ['********'],
97-
'Host' => ['********.example.com:9000'],
99+
'Host' => ['********.example.com:9000'],
98100
], $headers);
99101
}
100102

@@ -114,12 +116,12 @@ public function test_get_json()
114116
'foo' => 'bar',
115117
'baz' => [
116118
[
117-
'field_1' => 'value1',
118-
'field_2' => 'value2',
119+
'field_1' => 'value1',
120+
'field_2' => 'value2',
119121
'password' => '********',
120-
'secret' => 'this is not for everyone', // Note that keys are NOT filtered
121-
]
122-
]
122+
'secret' => 'this is not for everyone', // Note that keys are NOT filtered
123+
],
124+
],
123125
],
124126
], $json);
125127
}
@@ -133,12 +135,12 @@ public function test_get_content()
133135
'foo' => 'bar',
134136
'baz' => [
135137
[
136-
'field_1' => 'value1',
137-
'field_2' => 'value2',
138+
'field_1' => 'value1',
139+
'field_2' => 'value2',
138140
'password' => '********',
139-
'secret' => 'this is not for everyone', // Note that keys are NOT filtered
140-
]
141-
]
141+
'secret' => 'this is not for everyone', // Note that keys are NOT filtered
142+
],
143+
],
142144
],
143145
]), $content);
144146
}

0 commit comments

Comments
 (0)