Skip to content

Commit

Permalink
Fix some spacing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bulton-fr committed Nov 12, 2016
1 parent f94df3d commit 5f28fea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions src/DependencyTree.php
Expand Up @@ -25,11 +25,11 @@ class DependencyTree
public function addDependency($name, $order = 0, $dependencies = [])
{
//Check if dependency is already declared.
if(isset($this->dependencies[$name])) {
if (isset($this->dependencies[$name])) {
throw new Exception('Dependency '.$name.' already declared.');
}

if(!is_array($dependencies)) {
if (!is_array($dependencies)) {
throw new Exception('Dependencies must be passed in a array.');
}

Expand Down Expand Up @@ -65,7 +65,7 @@ protected function generateOrderTree()
$tree = new Tree;

//add all dependency to the Tree
foreach($this->dependencies as $dependencyName => $dependencyInfos) {
foreach ($this->dependencies as $dependencyName => $dependencyInfos) {
$tree->addDependency(
$dependencyName,
$dependencyInfos->order,
Expand All @@ -88,10 +88,10 @@ protected function generateDependenciesTree($orderTree)
//Read the orderTree and generate a tree
//for each line of the first tree

foreach($orderTree as $order => $dependencies) {
foreach ($orderTree as $order => $dependencies) {
$tree = new Tree;

foreach($dependencies as $dependencyName) {
foreach ($dependencies as $dependencyName) {
$dependencyInfos = $this->dependencies[$dependencyName];

$tree->addDependency(
Expand Down
42 changes: 21 additions & 21 deletions src/Tree.php
Expand Up @@ -48,11 +48,11 @@ class Tree
public function addDependency($name, $order = 0, $dependencies = [])
{
//Check if dependency is already declared.
if(isset($this->dependenciesInfos[$name])) {
if (isset($this->dependenciesInfos[$name])) {
throw new Exception('Dependency '.$name.' already declared.');
}

if(!is_array($dependencies)) {
if (!is_array($dependencies)) {
throw new Exception('Dependencies must be passed in a array.');
}

Expand All @@ -63,13 +63,13 @@ public function addDependency($name, $order = 0, $dependencies = [])
$this->dependenciesInfos[$name] = $dependencyInfos;

//Create the key for list of depends if she doesn't exist
if(!isset($this->listDepends[$name])) {
if (!isset($this->listDepends[$name])) {
$this->listDepends[$name] = [];
}

//Generate the list of depends
if($dependencies !== []) {
foreach($dependencies as $dependencyName) {
if ($dependencies !== []) {
foreach ($dependencies as $dependencyName) {
if(!isset($this->listDepends[$dependencyName])) {
$this->listDepends[$dependencyName] = [];
}
Expand All @@ -90,11 +90,11 @@ public function generateTree()
{
//Read all depencies declared and positioned each dependency on
//the tree with they order value
foreach($this->dependenciesInfos as $name => $dependency) {
foreach ($this->dependenciesInfos as $name => $dependency) {
$order = $dependency->order;

//If the line for this order not exist
if(!isset($this->tree[$order])) {
if (!isset($this->tree[$order])) {
$this->tree[$order] = [];
}

Expand All @@ -105,8 +105,8 @@ public function generateTree()

//Read the tree and check depends of each package.
//Move some package in the tree if need for depends.
foreach($this->tree as $dependencies) {
foreach($dependencies as $dependencyName) {
foreach ($this->tree as $dependencies) {
foreach ($dependencies as $dependencyName) {
$this->checkDepend($dependencyName);
}
}
Expand All @@ -132,17 +132,17 @@ protected function checkDepend($dependencyName)
$order = $dependencyInfos->order;

//No depends :)
if($listDepends === []) {
if ($listDepends === []) {
return;
}

//Read all depends and check if they correctly spoted.
//If not, call the method to move the depend read.
foreach($listDepends as $dependencyName) {
foreach ($listDepends as $dependencyName) {
$dependencyPos = $this->dependenciesPositions[$dependencyName];
$dependencyOrder = $dependencyPos[0];

if($dependencyOrder < $order) {
if ($dependencyOrder < $order) {
$this->moveDepend($dependencyName, $order);
}
}
Expand All @@ -163,7 +163,7 @@ protected function moveDepend($dependencyName, $newOrder)
$oldOrder = $dependencyInfos->order;

//If the new position not already exist in the tree
if(!isset($this->tree[$newOrder])) {
if (!isset($this->tree[$newOrder])) {
$this->tree[$newOrder] = [];
}

Expand Down Expand Up @@ -194,15 +194,15 @@ public function generateOrderFromDependencies()
$this->tree = [[]]; //generate a empty tree

//Read all depends of each dependencies
foreach($this->listDepends as $dependencyName => $depends) {
foreach ($this->listDepends as $dependencyName => $depends) {

//If the dependency in the depend's list is declared on this tree.
if (!isset($this->dependenciesInfos[$dependencyName])) {
continue;
}

//If the package have depends, we continue
if($depends !== []) {
if ($depends !== []) {
continue;
}

Expand All @@ -224,16 +224,16 @@ public function generateOrderFromDependencies()
$treeOrder = 0;

//Read the tree for update the order of each dependency
foreach($this->tree as $dependencies) {
foreach ($this->tree as $dependencies) {
if ($dependencies === []) {
continue;
}

foreach($dependencies as $dependencyName) {
foreach ($dependencies as $dependencyName) {
$dependencyInfos = &$this->dependenciesInfos[$dependencyName];

//If the order has not be already updated
if($dependencyInfos->order > -1) {
if ($dependencyInfos->order > -1) {
continue;
}

Expand All @@ -259,16 +259,16 @@ public function generateOrderFromDependencies()
protected function generateOrderForADependency($dependencyName, $currentOrder)
{
$depends = $this->dependenciesInfos[$dependencyName]->dependencies;
if($depends === []) {
if ($depends === []) {
return;
}

$order = $currentOrder+1;
if(!isset($this->tree[$order])) {
if (!isset($this->tree[$order])) {
$this->tree[$order] = [];
}

foreach($depends as $dependName) {
foreach ($depends as $dependName) {
//If the dependency of the dependency is in a other tree
if (!isset($this->dependenciesInfos[$dependName])) {
continue;
Expand Down

0 comments on commit 5f28fea

Please sign in to comment.