Skip to content

Commit ae24dcc

Browse files
committed
Improve method names
1 parent b77f2c8 commit ae24dcc

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/Redmine/Client/ClientApiTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ private function isUploadCall(string $path): bool
6161
return (false !== strpos($path, '/uploads.json')) || (false !== strpos($path, '/uploads.xml'));
6262
}
6363

64-
private function isUploadCallAndFilepath(string $path, string $body): bool
64+
private function isValidFilePath(string $body): bool
6565
{
6666
return
67-
$this->isUploadCall($path)
68-
&& '' !== $body
67+
'' !== $body
6968
&& strlen($body) <= \PHP_MAXPATHLEN
7069
&& is_file(strval(str_replace("\0", '', $body)))
7170
;

src/Redmine/Client/NativeCurlClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private function createCurl(string $method, string $path, string $body = '')
271271
switch ($method) {
272272
case 'post':
273273
$curlOptions[CURLOPT_POST] = 1;
274-
if ($this->isUploadCallAndFilepath($path, $body)) {
274+
if ($this->isUploadCall($path) && $this->isValidFilePath($body)) {
275275
@trigger_error('Uploading an attachment by filepath is deprecated, use file_get_contents() to upload the file content instead.', E_USER_DEPRECATED);
276276

277277
$file = fopen($body, 'r');

src/Redmine/Client/Psr18Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function createRequest(string $method, string $path, string $body = ''):
181181

182182
switch ($method) {
183183
case 'POST':
184-
if ($this->isUploadCallAndFilepath($path, $body)) {
184+
if ($this->isUploadCall($path) && $this->isValidFilePath($body)) {
185185
@trigger_error('Uploading an attachment by filepath is deprecated, use file_get_contents() to upload the file content instead.', E_USER_DEPRECATED);
186186

187187
$request = $request->withBody(

0 commit comments

Comments
 (0)