Пример #1
0
 private function assertFlatArrayMatchesDeepArray($flat, DotArray $dotArray)
 {
     foreach ($flat as $key => $value) {
         $this->assertSame($value, $dotArray->get($key));
     }
 }
Пример #2
0
 private function askForCustomOptionArray($currentValue, Option $option)
 {
     $da = new DotArray($currentValue);
     $this->stdio->outln($option->getPath());
     $this->stdio->outln($option->getDescription());
     $continue = true;
     while ($continue) {
         $this->stdio->displayList($da->flatten());
         $actions = ['delete', 'clear all', 'add', 'replace', 'skip'];
         $action = $this->stdio->chooseAction($actions);
         switch ($action) {
             case 'delete':
                 $index = $this->stdio->chooseFromList($da->flatten(), 'Item to delete', false);
                 if ($index !== null) {
                     $da->remove($index);
                 }
                 break;
             case 'clear all':
                 $da = new DotArray();
                 break;
             case 'add':
                 $newValue = $this->stdio->ask('Enter value of the new item');
                 $da = new DotArray(array_merge($da->getArray(), [$newValue]));
                 break;
             case 'replace':
                 $index = $this->stdio->chooseFromList($da->flatten(), 'Item to replace', false);
                 if ($index !== null) {
                     $da->set($index, $this->stdio->ask('Enter new value'));
                 }
                 break;
             case 'skip':
                 $continue = false;
                 break;
         }
     }
     $this->frontmatter->set($option->getPath(), $da->getArray());
 }