Skip to content

Commit

Permalink
Env typehint & style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwellss committed Dec 29, 2017
1 parent d83932b commit 0cdbdb2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Sphpeme/Env/AggregateEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sphpeme\Env;



class AggregateEnv implements EnvInterface
{
protected $extensions = [];
Expand All @@ -15,7 +13,7 @@ public function __construct(EnvInterface ...$envs)
}
}

public function __isset($prop): bool
public function __isset(string $prop): bool
{
foreach ($this->extensions as $extension) {
if (isset($extension->$prop)) {
Expand All @@ -42,4 +40,4 @@ public function __get(string $prop)

return false;
}
}
}
5 changes: 3 additions & 2 deletions Sphpeme/Env/BoolEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ public function not($arg): bool

/**
* @param $arg
* @return bool
* @return boo
*/
public function isBool($arg)
public
function isBool($arg)
{
return \is_bool($arg);
}
Expand Down
6 changes: 3 additions & 3 deletions Sphpeme/Env/EnvInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

interface EnvInterface
{
public function __get(string $pop);
public function __isset($prop): bool;
}
public function __get(string $prop);
public function __isset(string $prop): bool;
}
13 changes: 10 additions & 3 deletions Sphpeme/Env/MappedEnvTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

namespace Sphpeme\Env;


trait MappedEnvTrait
{
public function __isset($prop): bool
/**
* @param string $prop
* @return bool
*/
public function __isset(string $prop): bool
{
return (bool)$this->__get($prop);
}

/**
* @param string $prop
* @return mixed
*/
public function __get(string $prop)
{
if (isset(static::MAPPING[$prop])) {
Expand All @@ -20,4 +27,4 @@ public function __get(string $prop)
? [$this, $prop]
: $this->$prop;
}
}
}
5 changes: 2 additions & 3 deletions Sphpeme/Env/SimpleEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sphpeme\Env;


class SimpleEnv implements EnvInterface
{
/**
Expand All @@ -20,8 +19,8 @@ public function __get(string $prop)
return $this->members[$prop];
}

public function __isset($prop): bool
public function __isset(string $prop): bool
{
return isset($this->members[$prop]);
}
}
}

0 comments on commit 0cdbdb2

Please sign in to comment.