Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt aggregation base class to handle suffix #1887

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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';
}
}