ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CapabilityCollection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
31 public function __construct(
32 private array $capabilities
33 ) {
34 }
35
36 public function all(): array
37 {
38 return $this->capabilities;
39 }
40
41 public function get(Capabilities $capability): Capability|false
42 {
43 foreach ($this->capabilities as $cap) {
44 if ($cap->getCapability() === $capability) {
45 return $cap;
46 }
47 }
48 return false;
49 }
50
51 public function getBest(): Capability
52 {
53 foreach ($this->capabilities as $cap) {
54 if ($cap->isUnlocked()) {
55 return $cap;
56 }
57 }
58 return new Capability(Capabilities::NONE, Permissions::NONE);
59 }
60
61}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...