5d0907fbb4d75abc3936276f9d8b5d9e47aac823
[yaffs-website] / vendor / drupal / console-core / src / Command / Shared / InputTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Core\Command\Shared\InputTrait.
6  */
7
8 namespace Drupal\Console\Core\Command\Shared;
9
10 /**
11  * Class InputTrait
12  *
13  * @package Drupal\Console\Core\Command
14  */
15 trait InputTrait
16 {
17     /**
18      * @return array
19      */
20     private function inlineValueAsArray($inputValue)
21     {
22         $inputArrayValue = [];
23         foreach ($inputValue as $key => $value) {
24             if (!is_array($value)) {
25                 $separatorIndex = strpos($value, ':');
26                 if (!$separatorIndex) {
27                     continue;
28                 }
29                 $inputKeyItem = substr($value, 0, $separatorIndex);
30                 $inputValueItem = substr($value, $separatorIndex+1);
31                 $inputArrayValue[$key] = [$inputKeyItem => $inputValueItem];
32             }
33         }
34
35         return $inputArrayValue?$inputArrayValue:$inputValue;
36     }
37 }