Skip to content

Commit

Permalink
Adapt aggregation base class to handle suffix (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
deguif authored Dec 3, 2020
1 parent ef7b9e4 commit c9d01b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/Aggregation/AbstractAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Elastica\Exception\InvalidException;
use Elastica\NameableInterface;
use Elastica\Param;
use Elastica\Util;

abstract class AbstractAggregation extends Param implements NameableInterface
{
Expand Down Expand Up @@ -134,4 +135,12 @@ public function toArray(): array

return $array;
}

protected function _getBaseName()
{
$shortName = (new \ReflectionClass($this))->getShortName();
$shortName = \preg_replace('/Aggregation$/', '', $shortName);

return Util::toSnakeCase($shortName);
}
}
5 changes: 0 additions & 5 deletions src/Aggregation/GlobalAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@ public function toArray(): array

return $array;
}

protected function _getBaseName()
{
return 'global';
}
}
5 changes: 0 additions & 5 deletions src/Aggregation/ParentAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@ public function setType($type): self
{
return $this->setParam('type', $type);
}

protected function _getBaseName()
{
return 'parent';
}
}

0 comments on commit c9d01b6

Please sign in to comment.