Skip to content

Commit

Permalink
fix abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanbae committed Jun 10, 2021
1 parent 817ff95 commit 22f371f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jsanbae/metamorphoser",
"description": "Procesa tus arrays en diferentes etapas",
"type": "library",
"version": "1.1.2",
"version": "1.1.3",
"keywords": ["csv", "array", "collections", "process"],
"license": "MIT",
"authors": [
Expand Down
8 changes: 7 additions & 1 deletion src/Arrangers/AbstractArranger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

abstract class AbstractArranger extends PipeHandler implements Arranger {

protected $arranger = null;

/**
* Arrange the data
*
Expand All @@ -27,7 +29,11 @@ public function arrange(Dataset $_dataset):Dataset
*/
public function handle(Dataset $_dataset):Dataset
{
return parent::handle($this->arrange($_dataset));
if ($this->arranger) {
return parent::handle($this->arranger->arrange($_dataset));
} else {
return parent::handle($this->arrange($_dataset));
}
}

}
8 changes: 7 additions & 1 deletion src/Filters/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

abstract class AbstractFilter extends PipeHandler implements Filter {

protected $filter = null;

/**
* Filter the data
*
Expand All @@ -27,7 +29,11 @@ public function filter(Dataset $_dataset):Dataset
*/
public function handle(Dataset $_dataset):Dataset
{
return parent::handle($this->filter($_dataset));
if ($this->filter) {
return parent::handle($this->filter->filter($_dataset));
} else {
return parent::handle($this->filter($_dataset));
}
}

}
8 changes: 7 additions & 1 deletion src/Mutators/AbstractMutator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

abstract class AbstractMutator extends PipeHandler implements Mutator {

protected $mutator = null;

/**
* Mutate the data
*
Expand All @@ -34,7 +36,11 @@ public function mute(Dataset $_dataset):Dataset
*/
public function handle(Dataset $_dataset):Dataset
{
return parent::handle($this->mute($_dataset));
if ($this->mutator) {
return parent::handle($this->mutator->mute($_dataset));
} else {
return parent::handle($this->mute($_dataset));
}
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Validators/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

abstract class AbstractValidator extends PipeHandler implements Validator {

protected $validator = null;

/**
* validate the data
*
Expand All @@ -27,7 +29,12 @@ public function validate(Dataset $_dataset):Dataset
*/
public function handle(Dataset $_dataset):Dataset
{
return parent::handle($this->validate($_dataset));
if ($this->validator) {
return parent::handle($this->validator->validate($_dataset));
} else {
return parent::handle($this->validate($_dataset));
}

}

}

0 comments on commit 22f371f

Please sign in to comment.