Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / output-formatters / src / Validate / ValidDataTypesTrait.php
1 <?php
2 namespace Consolidation\OutputFormatters\Validate;
3
4 /**
5  * Provides a default implementation of isValidDataType.
6  *
7  * Users of this trait are expected to implement ValidDataTypesInterface.
8  */
9 trait ValidDataTypesTrait
10 {
11     /**
12      * Return the list of data types acceptable to this formatter
13      *
14      * @return \ReflectionClass[]
15      */
16     public abstract function validDataTypes();
17
18     /**
19      * Return the list of data types acceptable to this formatter
20      */
21     public function isValidDataType(\ReflectionClass $dataType)
22     {
23         return array_reduce(
24             $this->validDataTypes(),
25             function ($carry, $supportedType) use ($dataType) {
26                 return
27                     $carry ||
28                     ($dataType->getName() == $supportedType->getName()) ||
29                     ($dataType->isSubclassOf($supportedType->getName()));
30             },
31             false
32         );
33     }
34 }