Skip to content

Commit 682807d

Browse files
committed
Cleanup
1 parent 227103f commit 682807d

9 files changed

Lines changed: 16 additions & 24 deletions

File tree

src/Model/Activity.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ public function readLog(callable $onUpdate = null)
127127
private function readline(StreamInterface $stream, $newline = "\n") {
128128
$buffer = '';
129129
while (!$stream->eof()) {
130-
if (false === ($byte = $stream->read(1))) {
131-
return $buffer;
132-
}
130+
$byte = $stream->read(1);
133131
$buffer .= $byte;
134132
if ($byte === $newline) {
135133
break;
@@ -218,9 +216,13 @@ public function getDescription($html = false)
218216
}
219217

220218
/**
219+
* Formats a timestamp as RFC3339, to be used in the API's starts_at parameter.
220+
*
221221
* @param int|DateTime $timestamp UNIX UTC timestamp (seconds) or DateTime
222222
*
223-
* @return false|string 2022-02-22T02:00:00.000000+00:00
223+
* @throws \RuntimeException if the timestamp is invalid
224+
*
225+
* @return string 2022-02-22T02:00:00.000000+00:00
224226
*/
225227
public static function formatStartsAt($timestamp)
226228
{
@@ -232,13 +234,13 @@ public static function formatStartsAt($timestamp)
232234
// Parse the UNIX UTC timestamp (seconds) into a DateTime
233235
$date = DateTime::createFromFormat('U', $timestamp, new DateTimeZone("UTC"));
234236
}
235-
237+
236238
if (!$date) {
237239
throw new \RuntimeException(sprintf('Failed to format timestamp: %d', $timestamp));
238240
}
239-
241+
240242
# Sample: 2022-02-22T02:00:00.000000+00:00
241-
return $date = $date->format('Y-m-d\TH:i:s.uP');
243+
return $date->format('Y-m-d\TH:i:s.uP');
242244
}
243245

244246
/**

src/Model/Backups/BackupConfig.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
class BackupConfig
66
{
7-
/** @var \Platformsh\Client\Model\Backups\Policy */
8-
private $policies = [];
9-
10-
/** @var int */
7+
private $policies;
118
private $manualCount;
129

1310
/**
@@ -52,7 +49,7 @@ public function getManualCount()
5249
/**
5350
* Get a list of backup retention policies.
5451
*
55-
* @return \Platformsh\Client\Model\Backups\Policy[]
52+
* @return Policy[]
5653
*/
5754
public function getPolicies()
5855
{

src/Model/Organization/Member.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace Platformsh\Client\Model\Organization;
44

5-
use GuzzleHttp\ClientInterface;
65
use Platformsh\Client\Model\Ref\UserRef;
7-
use Platformsh\Client\Model\Resource;
86
use Platformsh\Client\Model\ResourceWithReferences;
97

108
/**

src/Model/Plan.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Platformsh\Client\Model;
44

5-
use GuzzleHttp\ClientInterface;
6-
75
/**
86
* Represents a Platform.sh plan.
97
*

src/Model/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function getVariables($limit = 0)
389389
* @param bool $json
390390
* Whether this variable's value is JSON-encoded.
391391
* @param bool $visibleBuild
392-
* Whether this this variable should be exposed during the build phase.
392+
* Whether this variable should be exposed during the build phase.
393393
* @param bool $visibleRuntime
394394
* Whether this variable should be exposed during deploy and runtime.
395395
* @param bool $sensitive

src/Model/Region.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Platformsh\Client\Model;
44

5-
use GuzzleHttp\ClientInterface;
6-
75
/**
86
* Represents a Platform.sh region.
97
*

src/Model/Resource.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function offsetUnset($offset)
134134
}
135135

136136
/**
137-
* Get all of the API data for this resource.
137+
* Get all the API data for this resource.
138138
*
139139
* @return array
140140
*/
@@ -620,8 +620,7 @@ protected function makeAbsoluteUrl($relativeUrl, $baseUrl = null)
620620
*/
621621
public function getPropertyNames()
622622
{
623-
$keys = array_filter(array_keys($this->data), [$this, 'isProperty']);
624-
return $keys;
623+
return array_filter(array_keys($this->data), [$this, 'isProperty']);
625624
}
626625

627626
/**

src/Model/ResourceWithReferences.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function wrapCollection(array $data, $baseUrl, ClientInterface $cl
5151
$item['ref:users'][$value] = $data['ref:users'][$value];
5252
}
5353
// And organization-related references.
54-
if (\in_array($key, ['organization_id']) && isset($data['ref:organizations'][$value])) {
54+
if ($key === 'organization_id' && isset($data['ref:organizations'][$value])) {
5555
$item['ref:organizations'][$value] = $data['ref:organizations'][$value];
5656
}
5757
}

src/SshCert/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private function readUint64(&$bytes) {
7878
// The 'J' format for pack/unpack was added in PHP 5.6.3.
7979
if (\version_compare(PHP_VERSION, '5.6.3', '<')) {
8080
list(, $most, $least) = \unpack('N2', $packed);
81-
return (int) (($most << 32) | $least);
81+
return ($most << 32) | $least;
8282
}
8383
return (int) \unpack('J', $packed)[1];
8484
}

0 commit comments

Comments
 (0)