Mercurial > hg > isophonics-drupal-site
annotate vendor/consolidation/annotated-command/src/AnnotationData.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 namespace Consolidation\AnnotatedCommand; |
Chris@0 | 3 |
Chris@0 | 4 use Consolidation\AnnotatedCommand\Parser\Internal\CsvUtils; |
Chris@0 | 5 |
Chris@0 | 6 class AnnotationData extends \ArrayObject |
Chris@0 | 7 { |
Chris@0 | 8 public function get($key, $default = '') |
Chris@0 | 9 { |
Chris@0 | 10 return $this->has($key) ? CsvUtils::toString($this[$key]) : $default; |
Chris@0 | 11 } |
Chris@0 | 12 |
Chris@0 | 13 public function getList($key, $default = []) |
Chris@0 | 14 { |
Chris@0 | 15 return $this->has($key) ? CsvUtils::toList($this[$key]) : $default; |
Chris@0 | 16 } |
Chris@0 | 17 |
Chris@0 | 18 public function has($key) |
Chris@0 | 19 { |
Chris@0 | 20 return isset($this[$key]); |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 public function keys() |
Chris@0 | 24 { |
Chris@0 | 25 return array_keys($this->getArrayCopy()); |
Chris@0 | 26 } |
Chris@17 | 27 |
Chris@17 | 28 public function set($key, $value = '') |
Chris@17 | 29 { |
Chris@17 | 30 $this->offsetSet($key, $value); |
Chris@17 | 31 return $this; |
Chris@17 | 32 } |
Chris@17 | 33 |
Chris@17 | 34 public function append($key, $value = '') |
Chris@17 | 35 { |
Chris@17 | 36 $data = $this->offsetGet($key); |
Chris@17 | 37 if (is_array($data)) { |
Chris@17 | 38 $this->offsetSet($key, array_merge($data, $value)); |
Chris@17 | 39 } elseif (is_scalar($data)) { |
Chris@17 | 40 $this->offsetSet($key, $data . $value); |
Chris@17 | 41 } |
Chris@17 | 42 return $this; |
Chris@17 | 43 } |
Chris@0 | 44 } |