| Total Complexity | 7 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | abstract class ModuleJoint |
||
| 8 | { |
||
| 9 | use Concerns\HasLinks; |
||
| 10 | use Concerns\HasAccessControl; |
||
| 11 | use Concerns\HasPackageManifest; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * List of runtime registered joints |
||
| 15 | * Can be used for tesing purposes |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected static $registry = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Make all joints which are applicable to static class and user has access to |
||
| 23 | * |
||
| 24 | * @return Collection |
||
| 25 | */ |
||
| 26 | final public static function collect() |
||
| 27 | { |
||
| 28 | $ret = collect(); |
||
| 29 | foreach (self::list() as $class) { |
||
| 30 | /** @var ModuleJoint $joint */ |
||
| 31 | $joint = new $class(); |
||
| 32 | |||
| 33 | if ($joint->access()) { |
||
| 34 | $ret->add($joint); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $ret; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * List all registered joints which are subclasses of static |
||
| 43 | */ |
||
| 44 | final public static function list() |
||
| 54 | }); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Collect all joints declared in the modules and return array |
||
| 59 | * |
||
| 60 | * @return array |
||
| 61 | */ |
||
| 62 | final public static function moduleJoints() |
||
| 70 | } |
||
| 71 | |||
| 72 | final public static function register($class) |
||
| 75 | } |
||
| 76 | } |