ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
CollectedObjective.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 namespace ILIAS\Setup\Metrics;
6 
7 use ILIAS\Setup;
8 
12 abstract class CollectedObjective implements Setup\Objective
13 {
17  protected $storage;
18 
19  public function __construct(Storage $storage)
20  {
21  $this->storage = $storage;
22  }
23 
33  abstract protected function collectFrom(Setup\Environment $environment, Storage $storage) : void;
34 
44  abstract protected function getTentativePreconditions(Setup\Environment $environment) : array;
45 
46  public function getHash() : string
47  {
48  return hash("sha256", static::class);
49  }
50 
51  public function getLabel() : string
52  {
53  return "Collect metrics.";
54  }
55 
56  public function isNotable() : bool
57  {
58  return false;
59  }
60 
61  public function getPreconditions(Setup\Environment $environment) : array
62  {
63  return array_map(
64  function (Setup\Objective $o) {
65  return new Setup\Objective\Tentatively($o);
66  },
67  $this->getTentativePreconditions($environment)
68  );
69  }
70 
71  public function achieve(Setup\Environment $environment) : Setup\Environment
72  {
73  $this->collectFrom($environment, $this->storage);
74  return $environment;
75  }
76 
80  public function isApplicable(Setup\Environment $environment) : bool
81  {
82  // We want to always collect fresh metrics.
83  return true;
84  }
85 }
achieve(Setup\Environment $environment)
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:14
isApplicable(Setup\Environment $environment)
getLabel()
Get a label that describes this objective.
getTentativePreconditions(Setup\Environment $environment)
Give preconditions that might or might not be fullfilled.
Base class to simplify collection of metrics.
getPreconditions(Setup\Environment $environment)
collectFrom(Setup\Environment $environment, Storage $storage)
Attempt to gather metrics based on the provided environment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getHash()
Get a hash for this objective.
An environment holds resources to be used in the setup process.
Definition: Environment.php:11
isNotable()
Get to know if this is an interesting objective for a human.