コード例 #1
0
 /**
  * Load the environment file, while ensuring read permissions or die trying!
  *
  * @return File
  */
 protected function get_env_for_write_or_fail()
 {
     try {
         return File::writable($this->resolve_file_path())->load();
     } catch (\Exception $e) {
         WP_CLI::error($e->getMessage());
     }
 }
コード例 #2
0
 /**
  * Update salts in the environment file.
  *
  * @param bool $force Whether or not to force update any existing values
  *
  * @return Collection
  */
 protected function update_salts($force = false)
 {
     return $this->salts->map(function ($salt) use($force) {
         list($key, $value) = $salt;
         if (!$force && $this->env->hasKey($key)) {
             WP_CLI::line("The '{$key}' already exists, skipping.");
             $salt['skipped'] = true;
             return $salt;
         }
         $this->env->set($key, $value, "'");
         return $salt;
     });
 }
コード例 #3
0
 /**
  * @test
  */
 public function it_can_return_an_array_of_key_value_line_pairs()
 {
     $path = $this->get_fixture_path('env-basic');
     $env = new File($path);
     $env->load();
     $this->assertCount(1, $env->dictionary());
 }
コード例 #4
0
 /**
  * Iterate over each line and prompt for a new value
  *
  * @param File $env
  *
  * @return int
  */
 protected function prompt_all(File $env)
 {
     $env->dictionary()->each(function ($value, $key) use($env) {
         $env->set($key, $this->prompt($key, $value));
     });
     $env->save();
 }