Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Feb 2, 2017
1 parent 0eed441 commit 2a32a99
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/ManipulationSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class ManipulationSequence implements IteratorAggregate
/** @var bool */
protected $startNewGroup = true;

public function __construct(array $sequenceArray = [])
{
$this->mergeArray($sequenceArray);
}

/**
* @param string $operation
* @param string $argument
Expand All @@ -38,6 +43,10 @@ public function merge(ManipulationSequence $sequence)
{
$sequenceArray = $sequence->toArray();

$this->mergeArray($sequenceArray);
}

public function mergeArray(array $sequenceArray) {
foreach ($sequenceArray as $group) {
foreach ($group as $name => $argument) {
$this->addManipulation($name, $argument);
Expand Down
3 changes: 2 additions & 1 deletion src/Manipulations.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class Manipulations

public function __construct(array $manipulations = [])
{
$this->manipulationSequence = new ManipulationSequence();
$this->manipulationSequence = new ManipulationSequence($manipulations);

}

/**
Expand Down
18 changes: 18 additions & 0 deletions tests/ManipulationSequenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,22 @@ public function it_is_serializable()

$this->assertEquals($sequence->toArray(), $unserializedSequence->toArray());
}

/** @test */
public function it_can_be_constructed_with_a_sequence_array()
{
$sequenceArray = [
[
'greyscale' => '',
'width' => 50,
],
[
'height' => 100,
]
];

$sequence = (new ManipulationSequence($sequenceArray));

$this->assertEquals($sequenceArray, $sequence->toArray());
}
}
18 changes: 18 additions & 0 deletions tests/ManipulationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,22 @@ public function it_can_be_serialized()
$unserializedManipulations->getManipulationSequence()->toArray()
);
}

/** @test */
public function it_can_be_constructed_with_a_sequence_array()
{
$sequenceArray = [
[
'greyscale' => '',
'width' => 50,
],
[
'height' => 100,
]
];

$manipulations = (new Manipulations($sequenceArray));

$this->assertEquals($sequenceArray, $manipulations->getManipulationSequence()->toArray());
}
}

0 comments on commit 2a32a99

Please sign in to comment.