Skip to content

Commit

Permalink
Better naming helpers. (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Apr 5, 2023
1 parent 4da2b4a commit 49186a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/ActiveQuery.php
Expand Up @@ -14,7 +14,7 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Helper\ArrayHelper;
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\Query\BatchQueryResultInterface;
use Yiisoft\Db\Query\Query;
use Yiisoft\Db\Query\QueryInterface;
Expand Down Expand Up @@ -272,7 +272,7 @@ public function populate(array $rows, Closure|string|null $indexBy = null): arra
$this->addInverseRelations($models);
}

return ArrayHelper::populate($models, $indexBy);
return DbArrayHelper::populate($models, $indexBy);
}

/**
Expand Down Expand Up @@ -1099,7 +1099,7 @@ protected function findByCondition(mixed $condition): static
$condition = [$condition];
}

if (!ArrayHelper::isAssociative($condition) && !$condition instanceof ExpressionInterface) {
if (!DbArrayHelper::isAssociative($condition) && !$condition instanceof ExpressionInterface) {
/** query by primary key */
$primaryKey = $arInstance->primaryKey();

Expand Down
4 changes: 2 additions & 2 deletions src/BaseActiveRecord.php
Expand Up @@ -17,7 +17,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Exception\StaleObjectException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Helper\StringHelper;
use Yiisoft\Db\Helper\DbStringHelper;

use function array_combine;
use function array_flip;
Expand Down Expand Up @@ -1191,7 +1191,7 @@ private function resetDependentRelations(string $attribute): void
public function getTableName(): string
{
if ($this->tableName === '') {
$this->tableName = '{{%' . StringHelper::pascalCaseToId(StringHelper::baseName(static::class)) . '}}';
$this->tableName = '{{%' . DbStringHelper::pascalCaseToId(DbStringHelper::baseName(static::class)) . '}}';
}

return $this->tableName;
Expand Down
8 changes: 4 additions & 4 deletions tests/ActiveQueryTest.php
Expand Up @@ -28,7 +28,7 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\StaleObjectException;
use Yiisoft\Db\Exception\UnknownPropertyException;
use Yiisoft\Db\Helper\ArrayHelper;
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\Query\QueryInterface;

use function sort;
Expand Down Expand Up @@ -1934,13 +1934,13 @@ public function testOutdatedViaTableRelationsAreReset(): void
$orderQuery = new ActiveQuery(Order::class, $this->db);

$orders = $orderQuery->findOne(1);
$orderItemIds = ArrayHelper::getColumn($orders->items, 'id');
$orderItemIds = DbArrayHelper::getColumn($orders->items, 'id');
sort($orderItemIds);
$this->assertSame([1, 2], $orderItemIds);

$orders->id = 2;
sort($orderItemIds);
$orderItemIds = ArrayHelper::getColumn($orders->items, 'id');
$orderItemIds = DbArrayHelper::getColumn($orders->items, 'id');
$this->assertSame([3, 4, 5], $orderItemIds);

unset($orders->id);
Expand All @@ -1950,7 +1950,7 @@ public function testOutdatedViaTableRelationsAreReset(): void
$this->assertSame([], $order->items);

$order->id = 3;
$orderItemIds = ArrayHelper::getColumn($order->items, 'id');
$orderItemIds = DbArrayHelper::getColumn($order->items, 'id');
$this->assertSame([2], $orderItemIds);
}

Expand Down

0 comments on commit 49186a3

Please sign in to comment.