Skip to content

Commit

Permalink
chore: Use str_contains when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Sep 28, 2023
1 parent 486032c commit 25c80a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected function getContextualQuery(
// Add ordering
if (null !== $orderBy) {
foreach ($orderBy as $key => $value) {
if (false !== \mb_strpos($key, 'node.')) {
if (\str_contains($key, 'node.')) {
$simpleKey = str_replace('node.', '', $key);
$qb->addOrderBy(static::NODE_ALIAS . '.' . $simpleKey, $value);
} else {
Expand Down Expand Up @@ -653,7 +653,7 @@ protected function prepareComparisons(array &$criteria, QueryBuilder $qb, $alias

if (!$event->isPropagationStopped()) {
$baseKey = $simpleQB->getParameterKey($key);
if (false !== \mb_strpos($key, 'node.nodeType.')) {
if (\str_contains($key, 'node.nodeType.')) {
if (!$this->hasJoinedNode($qb, $alias)) {
$qb->innerJoin($alias . '.node', static::NODE_ALIAS);
}
Expand All @@ -663,7 +663,7 @@ protected function prepareComparisons(array &$criteria, QueryBuilder $qb, $alias
$prefix = static::NODETYPE_ALIAS . '.';
$simpleKey = str_replace('node.nodeType.', '', $key);
$qb->andWhere($simpleQB->buildExpressionWithoutBinding($value, $prefix, $simpleKey, $baseKey));
} elseif (false !== \mb_strpos($key, 'node.')) {
} elseif (\str_contains($key, 'node.')) {
if (!$this->hasJoinedNode($qb, $alias)) {
$qb->innerJoin($alias . '.node', static::NODE_ALIAS);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/RoadizCoreBundle/src/Repository/TagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,19 @@ protected function prepareComparisons(array &$criteria, QueryBuilder $qb, $alias
// Dots are forbidden in field definitions
$baseKey = $simpleQB->getParameterKey($key);

if (false !== \mb_strpos($key, 'translation.')) {
if (\str_contains($key, 'translation.')) {
/*
* Search in translation fields
*/
$prefix = static::TRANSLATION_ALIAS . '.';
$key = str_replace('translation.', '', $key);
} elseif (false !== \mb_strpos($key, 'nodes.')) {
} elseif (\str_contains($key, 'nodes.')) {
/*
* Search in node fields
*/
$prefix = static::NODE_ALIAS . '.';
$key = str_replace('nodes.', '', $key);
} elseif (false !== \mb_strpos($key, 'translatedTag.')) {
} elseif (\str_contains($key, 'translatedTag.')) {
/*
* Search in translatedTags fields
*/
Expand Down

0 comments on commit 25c80a0

Please sign in to comment.