/**
  * Returns the environments.
  *
  * @return Environment[]
  *      The environments.
  *
  * @throws \commpress\Cli\Service\Database\Exception\DatabaseQueryException
  *      If something goes wrong while querying the data.
  */
 public function getEnvironments()
 {
     $result = $this->database->query('SELECT * FROM ' . self::TABLE_ENVIRONMENTS);
     if (!$result) {
         throw new DatabaseQueryException('Failed to load environments from database.');
     }
     $environments = [];
     while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
         $environment = new Environment();
         // TODO: Get rid of the new operator (Builder-Pattern).
         $environment->setId($row[Environment::FIELD_ID]);
         $environment->setProjectId($row[Environment::FIELD_PROJECT_ID]);
         $environment->setBranch($row[Environment::FIELD_BRANCH]);
         $environment->setContainerIds($row[Environment::FIELD_CONTAINER_IDS]);
         $environments[] = $environment;
     }
     return $environments;
 }
 /**
  * {@inheritdoc}
  */
 public static function buildEntity(array $data)
 {
     $environment = new Environment();
     if (!empty($data[Entity::FIELD_ID])) {
         $environment->setId($data[Entity::FIELD_ID]);
     }
     $environment->setProjectId($data[Environment::FIELD_PROJECT_ID]);
     $environment->setBranch($data[Environment::FIELD_BRANCH]);
     $environment->setContainerIds($data[Environment::FIELD_CONTAINER_IDS]);
     return $environment;
 }