Esempio n. 1
0
 /**
  * Updates a single value with replacement for given key in yml file.
  *
  * @param string $key
  * @param string $value
  *
  * @return boolean
  */
 public function change($key, $value, $makebackup = true)
 {
     $pattern = str_replace('/', ':.*', $key);
     preg_match_all('/^' . $pattern . '(:\\s*)/mis', $this->file->read(), $matches, PREG_OFFSET_CAPTURE);
     if (count($matches[0]) > 0 && count($matches[1])) {
         $index = $matches[1][0][1] + strlen($matches[1][0][0]);
     } else {
         return false;
     }
     $line = substr_count($this->file->read(), "\n", 0, $index);
     $this->yaml[$line] = preg_replace('/^(.*?):(.*)/', '$1: ' . $this->prepareValue($value), $this->yaml[$line]);
     return $this->save($makebackup);
 }
Esempio n. 2
0
 public function testDelete()
 {
     $file = new File($this->filesystem, 'fixtures/base.css');
     $file->copy('temp/drop-the-base.css');
     $newFile = new File($this->filesystem, 'temp/drop-the-base.css');
     $this->assertSame($file->read(), $newFile->read());
     $newFile->delete();
     $this->assertFalse($newFile->exists());
     $newNewFile = new File($this->filesystem, 'temp/drop-the-base.css');
     $this->assertFalse($newNewFile->exists());
 }