Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
:octocat: not sure about Env here...
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Apr 22, 2018
1 parent 0532619 commit 02560c0
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/Container.php
Expand Up @@ -29,7 +29,7 @@ trait Container{
* @param \chillerlan\Traits\DotEnv|null $env
*/
public function __construct(array $properties = null, DotEnv $env = null){
$this->env = $env;
# $this->env = $env;

if(!empty($properties)){
$this->__fromIterable($properties);
Expand All @@ -44,18 +44,13 @@ public function __construct(array $properties = null, DotEnv $env = null){
*/
public function __get(string $property){


# if(method_exists($this, 'get_'.$property) && $this->__isset($property)){
# return call_user_func([$this, 'get_'.$property]);
# }

if($this->__isset($property)){
return $this->{$property};
}

if(property_exists($this, 'env') && $this->env instanceof DotEnv){
return $this->env->get($property);
}
# if(property_exists($this, 'env') && $this->env instanceof DotEnv){
# return $this->env->get($property);
# }

return null;
}
Expand All @@ -68,21 +63,16 @@ public function __get(string $property){
*/
public function __set(string $property, $value){

# if(method_exists($this, 'set_'.$property) && !$this->__isPrivate($property)){
# call_user_func_array([$this, 'set_'.$property], [$value]);
# return;
# }

// avoid overwriting private properties
if(property_exists($this, $property) && !$this->__isPrivate($property)){
$this->{$property} = $value;
return;
}

if(property_exists($this, 'env') && $this->env instanceof DotEnv){
$this->env->set($property, $value);
return;
}
# if(property_exists($this, 'env') && $this->env instanceof DotEnv){
# $this->env->set($property, $value);
# return;
# }

return; // should not see me
}
Expand All @@ -94,7 +84,8 @@ public function __set(string $property, $value){
*/
public function __isset(string $property):bool{
return (isset($this->{$property}) && !$this->__isPrivate($property))
|| (property_exists($this, 'env') && $this->env instanceof DotEnv && $this->env->get($property));
# || (property_exists($this, 'env') && $this->env instanceof DotEnv && $this->env->get($property))
;
}

/**
Expand Down

0 comments on commit 02560c0

Please sign in to comment.