Skip to content

Commit

Permalink
removing redundant "is_string" checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Apr 14, 2018
1 parent 5f0259e commit 4bae4e6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 60 deletions.
5 changes: 1 addition & 4 deletions src/Agent/AgentClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,7 @@ public function updateTTL(string $checkID, string $output, string $status) {
$status = Consul::HealthCritical;
break;
default:
return new Error(sprintf(
'%s is not a valid status. Allowed: ["pass", "warn", "fail"]',
is_string($status) ? $status : gettype($status)
));
return new Error("\"{$status}\" is not a valid status. Allowed: [\"pass\", \"warn\", \"fail\"]");
}

$r = new Request('PUT',
Expand Down
7 changes: 0 additions & 7 deletions src/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public static function getDefaultFormat(): string {
* @param string $format
*/
public static function setDefaultFormat(string $format) {
if (!is_string($format)) {
throw new \InvalidArgumentException(sprintf(
'PHPConsulAPI - DateTime::setDefaultFormat expects argument 1 to be string, %s seen.',
gettype($format)
));
}

if (false === @date($format)) {
throw new \InvalidArgumentException(sprintf(
'PHPConsulAPI - DateTime::setDefaultFormat specified invalid format "%s". Please see http://php.net/manual/en/function.date.php.',
Expand Down
10 changes: 0 additions & 10 deletions src/KV/KVClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ class KVClient extends AbstractClient {
* )
*/
public function get(string $key, QueryOptions $options = null): array {
if (!is_string($key)) {
return [null,
null,
new Error(sprintf(
'%s::get - Key expected to be string, %s seen.',
get_class($this),
gettype($key)
))];
}

$r = new Request('GET', sprintf('v1/kv/%s', $key), $this->config);
$r->setQueryOptions($options);

Expand Down
39 changes: 0 additions & 39 deletions src/Session/SessionClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ public function create(SessionEntry $sessionEntry = null, WriteOptions $options
* )
*/
public function destroy(string $id, WriteOptions $options = null): array {
if (!is_string($id)) {
return [null,
new Error(sprintf(
'%s::destroy - "$id" must be string, %s seen.',
get_class($this),
gettype($id)
))];
}

$r = new Request('PUT', sprintf('v1/session/destroy/%s', $id), $this->config);
$r->setWriteOptions($options);

Expand All @@ -134,16 +125,6 @@ public function destroy(string $id, WriteOptions $options = null): array {
* )
*/
public function renew(string $id, WriteOptions $options = null): array {
if (!is_string($id)) {
return [null,
null,
new Error(sprintf(
'%s::renew - "$id" must be string, %s seen.',
get_class($this),
gettype($id)
))];
}

$r = new Request('PUT', sprintf('v1/session/renew/%s', $id), $this->config);
$r->setWriteOptions($options);

Expand Down Expand Up @@ -191,16 +172,6 @@ public function renew(string $id, WriteOptions $options = null): array {
* )
*/
public function info(string $id, QueryOptions $options = null): array {
if (!is_string($id)) {
return [null,
null,
new Error(sprintf(
'%s::info - "$id" must be string, %s seen.',
get_class($this),
gettype($id)
))];
}

$r = new Request('GET', sprintf('v1/session/info/%s', $id), $this->config);
$r->setQueryOptions($options);

Expand Down Expand Up @@ -235,16 +206,6 @@ public function info(string $id, QueryOptions $options = null): array {
* )
*/
public function node(string $node, QueryOptions $options = null): array {
if (!is_string($node)) {
return [null,
null,
new Error(sprintf(
'%s::node - "$node" must be string, %s seen.',
get_class($this),
gettype($node)
))];
}

$r = new Request('GET', sprintf('v1/session/node/%s', $node), $this->config);
$r->setQueryOptions($options);

Expand Down

0 comments on commit 4bae4e6

Please sign in to comment.