Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
283ccfc
chore: improve DependencyBuilder
RobinTheHood Mar 6, 2023
e12d3ed
chore: improve DependencyManager
RobinTheHood Mar 6, 2023
386b947
refactor: make code more readable
RobinTheHood Mar 7, 2023
23b4580
refactor: add new methods and make code more readable
RobinTheHood Mar 7, 2023
e9035a0
chore: add class Counter and CounterTest
RobinTheHood Mar 7, 2023
3411401
chore: add class CombinationIterator
RobinTheHood Mar 7, 2023
e80e665
chore: use CombinationIterator
RobinTheHood Mar 7, 2023
374f40f
chore: improve code
RobinTheHood Mar 7, 2023
12fe832
chore: improve code
RobinTheHood Mar 7, 2023
ebd767e
chore: improve code
RobinTheHood Mar 7, 2023
d480dbb
chore: handle modified compatibility
RobinTheHood Mar 7, 2023
64b104e
chore: handle php version
RobinTheHood Mar 9, 2023
bfb5d50
chore: handle mmlc version
RobinTheHood Mar 9, 2023
c745c43
chore: add and use CombinationSatisfyerResult
RobinTheHood Mar 9, 2023
6602c22
chore: add overwrite and strip methods to Combination
RobinTheHood Mar 9, 2023
d23e445
chore: add resetCache methods for ModuleLoader and RemoteLoaderLoader
RobinTheHood Mar 9, 2023
b4b910c
chore: add class SystemSetFactory
RobinTheHood Mar 9, 2023
eade87e
chore: use new DependencyManager
RobinTheHood Mar 9, 2023
52d693f
fix: errros
RobinTheHood Mar 9, 2023
8db755f
chore: set default mmlc version
RobinTheHood Mar 9, 2023
545447b
test: add CombinationTest
RobinTheHood Mar 9, 2023
03f61fd
Merge branch 'master' into feat/86-new-dependency-resolver
RobinTheHood Mar 12, 2023
f594bb0
Merge branch 'master' into feat/86-new-dependency-resolver
RobinTheHood Mar 17, 2023
673670a
Merge branch 'master' into feat/86-new-dependency-resolver
RobinTheHood Mar 23, 2023
b4eb6be
feat: add Comparator:satisfiesAnd() and refactor Comparator:satisfies()
RobinTheHood Mar 26, 2023
9a17abd
feat: add 3 new methods: createConstraint(), createConstraintFromCons…
RobinTheHood Mar 26, 2023
8d97dcf
feat: add new methods and tests SystemSet::getArchiveNames() and Syst…
RobinTheHood Mar 26, 2023
e4d6c20
feat: add class and test Comstraint
RobinTheHood Mar 26, 2023
b9ce5ec
style: improve coding style
RobinTheHood Mar 26, 2023
497a01c
feat: check whether the version to be installed is compatible with th…
RobinTheHood Mar 26, 2023
8835279
refactor: use DependencyException instead of Exception
RobinTheHood Mar 27, 2023
905c0b2
feat: add ban icon to error message
RobinTheHood Mar 27, 2023
13df422
fix: make installed version updateable again
RobinTheHood Mar 27, 2023
7375bc2
fix: add missing use statement
RobinTheHood Mar 27, 2023
fb3e242
feat: add class FailLog
RobinTheHood Mar 28, 2023
ed36342
feat: add method __toString() to Combination
RobinTheHood Mar 28, 2023
10ac4ae
feat: add method getAll() to Combination
RobinTheHood Mar 28, 2023
6ef066f
chore: rebase changes
RobinTheHood Mar 28, 2023
e5fe5fe
fix: go to installed version url
RobinTheHood Mar 28, 2023
92c9a63
chore: rebase changes
RobinTheHood Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 0 additions & 229 deletions src/Classes/DependencyBuilder.php

This file was deleted.

104 changes: 104 additions & 0 deletions src/Classes/DependencyManager/Combination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

/*
* This file is part of MMLC - ModifiedModuleLoaderClient.
*
* (c) Robin Wieschendorf <mail@robinwieschendorf.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace RobinTheHood\ModifiedModuleLoaderClient\DependencyManager;

class Combination
{
/** @var array<string, string> */
private $combinations = [];

/**
* @return array<string, string>
*/
public function getAll(): array
{
return $this->combinations;
}

public function add(string $archiveName, string $version): void
{
if (array_key_exists($archiveName, $this->combinations)) {
throw new DependencyException($archiveName . ' is already set.');
}

$this->combinations[$archiveName] = $version;
}

public function overwrite(string $archiveName, string $version): void
{
$this->combinations[$archiveName] = $version;
}

public function getVersion(string $archiveName): string
{
if (!array_key_exists($archiveName, $this->combinations)) {
throw new DependencyException('Version of ' . $archiveName . ' not found.');
}

return $this->combinations[$archiveName];
}

public function clone(): Combination
{
$combinations = $this->combinations; // clones an array
$newCombination = new Combination();
$newCombination->combinations = $combinations;
return $newCombination;
}

/**
* Liefert eine neues Combinations Obj zurück, in der nur echte Module enthalten sind
*
* Einträge, wie modified, php, mmlc werden entfernt.
*
* @return Combination Liefert ein Combination Obj nur mit echten Modulen
*/
public function strip(): Combination
{
$combination = new Combination();
foreach ($this->combinations as $archiveName => $version) {
if (!$this->isArchiveName($archiveName)) {
continue;
}

$combination->add($archiveName, $version);
}
return $combination;
}

/**
* Überprüft, ob es sich um einen gültigen ArchvieName handelt
*
* @param string $archiveName Ein ArchiveName
* @return bool Liefert true, wenn $archiveName ein gültiger ArchvieName ist
*/
private function isArchiveName(string $archiveName): bool
{
if (strpos($archiveName, '/') === false) {
return false;
}

return true;
}


public function __toString(): string
{
$strings = [];
foreach ($this->combinations as $archiveName => $version) {
$strings[] = "$archiveName v$version";
}
return implode(', ', $strings);
}
}
57 changes: 57 additions & 0 deletions src/Classes/DependencyManager/CombinationBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of MMLC - ModifiedModuleLoaderClient.
*
* (c) Robin Wieschendorf <mail@robinwieschendorf.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace RobinTheHood\ModifiedModuleLoaderClient\DependencyManager;

class CombinationBuilder
{
/**
* @param FlatEntry[] $flatEntries
*
* @return Combination[]
*/
public function buildAllFromModuleFlatEntries($flatEntries): array
{
$combinations = [];
$flatEntries = array_values($flatEntries);
$this->buildAllCombinationsFromModuleFlatEntries($flatEntries, $combinations, new Combination(), 0);
return $combinations;
}

/**
* @param FlatEntry[] $flatEntries
* @param Combination[] $combinations
* @param Combination $combination
* @param int $index
*/
private function buildAllCombinationsFromModuleFlatEntries(
array &$flatEntries,
array &$combinations,
Combination $combination,
int $index
): void {
/** @var FlatEntry*/
$flatEntry = $flatEntries[$index] ?? [];

if (!$flatEntry) {
$combinations[] = $combination;
return;
}

foreach ($flatEntry->versions as $versionStr) {
$newCombination = $combination->clone();
$newCombination->add($flatEntry->archiveName, $versionStr);
$this->buildAllCombinationsFromModuleFlatEntries($flatEntries, $combinations, $newCombination, $index + 1);
}
}
}
Loading