Esempio n. 1
0
 /**
  * Assert that the callback returns true for each variable.
  *
  * @param callable $callback
  * @param string $message
  * @return Validator
  */
 private function assertCallback(callable $callback, $message = 'failed callback assertion')
 {
     $variablesFailingAssertion = [];
     foreach ($this->variables as $variableName) {
         $variableValue = $this->loader->getVariable($variableName);
         if (call_user_func($callback, $variableValue) === false) {
             $variablesFailingAssertion[] = $variableName . " {$message}";
         }
     }
     if (count($variablesFailingAssertion) > 0) {
         throw new RuntimeException(sprintf('One or more environment variables failed assertions: %s', implode(', ', $variablesFailingAssertion)));
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Load the files and set new environment variables
  * overwriting the existing ones.
  *
  * @return DotEnv
  */
 public function overload()
 {
     $this->loader = new Loader($this->files);
     $this->loader->load();
     return $this;
 }