Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
FileType
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 getDependenciesOfType
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2/** @noinspection PhpUnhandledExceptionInspection */
3declare(strict_types=1);
4
5enum FileType: string
6{
7  case SYSTEMCHECK = 'SysCheck';
8  case TESTTAKERS = 'Testtakers';
9  case BOOKLET = 'Booklet';
10  case UNIT = 'Unit';
11  case RESOURCE = 'Resource';
12
13  /**
14   * Returns the types of the input type and its dependencies in the correct order.
15   * @return string[]
16   */
17  public static function getDependenciesOfType(self $dependantType): array {
18    $leftDepOnRight = [
19      self::SYSTEMCHECK->value,
20      self::TESTTAKERS->value,
21      self::BOOKLET->value,
22      self::UNIT->value,
23      self::RESOURCE->value,
24    ];
25    $dependencies = [];
26
27    $dependencyStartsHere = false;
28    foreach ($leftDepOnRight as $dependency) {
29      if ($dependencyStartsHere) {
30        $dependencies[] = $dependency;
31        break;
32      }
33
34      if ($dependency == $dependantType->value) {
35        $dependencyStartsHere = true;
36        $dependencies[] = $dependency;
37      }
38    }
39
40    return $dependencies;
41  }
42}