| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 7 | class TravisYMLHelper |
||
| 8 | { |
||
| 9 | |||
| 10 | /** @var string */ |
||
| 11 | private $travisFileName = '.travis.yml'; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * TravisYMLHelper constructor. |
||
| 15 | * |
||
| 16 | * @param string $travisFileName The name of the travis config file, by default .travis.yml, but injectable for |
||
| 17 | * testing purposes |
||
| 18 | */ |
||
| 19 | public function __construct(string $travisFileName = '.travis.yml') |
||
| 22 | } |
||
| 23 | |||
| 24 | |||
| 25 | /** |
||
| 26 | * Load the Travis file, or default to an empty array if it does not exist |
||
| 27 | * |
||
| 28 | * @todo Change this behavior? |
||
| 29 | * @return mixed The Travis YAML file as an array (note Symfony returns mixed) |
||
| 30 | */ |
||
| 31 | public function loadTravis() |
||
| 32 | { |
||
| 33 | $result = []; |
||
| 34 | $path = \getcwd() . '/' . $this->travisFileName; |
||
| 35 | if (\file_exists($this->travisFileName)) { |
||
| 36 | $result = Yaml::parseFile($path); |
||
| 37 | } |
||
| 38 | |||
| 39 | return $result; |
||
| 40 | } |
||
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * Save a travis file, default .travis.yml, in the root of a project |
||
| 45 | * |
||
| 46 | * @todo How does one specifiy this as an associative array? |
||
| 47 | * @param array<string> $yamlArray an array that ought to have been formed from a YAML file |
||
| 48 | */ |
||
| 49 | public function saveTravis(array $yamlArray): void |
||
| 53 | } |
||
| 54 | } |
||
| 55 |