Skip to content

Commit

Permalink
Rename remove Record to deleteRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-boudry committed Oct 14, 2024
1 parent d829768 commit be44997
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/DataDrivers/PdoSql/PdoSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PdoSql implements WritableDriver

protected readonly PDOStatement $STMT_keyExist;
protected readonly PDOStatement $STMT_getRecordKey;
protected readonly PDOStatement $STMT_remove;
protected readonly PDOStatement $STMT_delete;

public function __construct(
public readonly PDO $db,
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct(
';'
);

$this->STMT_remove = $this->db->prepare(
$this->STMT_delete = $this->db->prepare(
'DELETE FROM ' . $this->escapeTableName() . ' ' .
'WHERE ' . $this->escapePrimaryKeyColumnName() . ' = ? ' .
';'
Expand Down Expand Up @@ -161,10 +161,10 @@ public function setRecordColumn(int $recordKey, int|string $columnKey, mixed $co
throw new FeatureNotImplementedYet;
}

public function removeRecord(int $recordKey): void
public function deleteRecord(int $recordKey): void
{
$this->STMT_remove->bindValue(1, $recordKey, PDO::PARAM_INT);
$this->STMT_remove->execute();
$this->STMT_delete->bindValue(1, $recordKey, PDO::PARAM_INT);
$this->STMT_delete->execute();
}

public function keyExist(int $recordKey): bool
Expand Down
2 changes: 1 addition & 1 deletion src/DataDrivers/PhpArray/PhpArrayDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addRecord(array $recordData): void
$this->data[] = $recordData;
}

public function removeRecord(int $recordKey): void
public function deleteRecord(int $recordKey): void
{
$this->mustHaveValidRecordKey($recordKey);

Expand Down
2 changes: 1 addition & 1 deletion src/DataDrivers/WritableDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public function setRecordColumn(int $recordKey, int|string $columnKey, mixed $co

public function addRecord(array $recordData): void;

public function removeRecord(int $recordKey): void;
public function deleteRecord(int $recordKey): void;
}
2 changes: 1 addition & 1 deletion src/DataFrameAccessors.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function offsetSet(mixed $index, mixed $row): void
*/
public function offsetUnset(mixed $offset): void
{
$this->removeRecord($offset);
$this->deleteRecord($offset);
}

/* *****************************************************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/DataFramePrimitives.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ public function updateCell(int $recordKey, string $column, mixed $newValue): sta
* Remove a record by key
* @throws KeyNotExistException
*/
public function removeRecord(int $key): static
public function deleteRecord(int $key): static
{
$this->mustBeWritableDriver();

$this->data->removeRecord($key);
$this->data->deleteRecord($key);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Statements/Delete/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute(): DataFrame
*/
public function record(int $key): DataFrame
{
return $this->getLinkedDataFrame()->removeRecord($key);
return $this->getLinkedDataFrame()->deleteRecord($key);
}

/**
Expand All @@ -40,7 +40,7 @@ public function filter(Closure $f): DataFrame

foreach ($this as $recordKey => $recordData) {
if ($f($recordData, $recordKey) === true) {
$df->removeRecord($recordKey);
$df->deleteRecord($recordKey);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/DataDrivers/DataDriversUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getIterator(): ArrayIterator
->toThrow(DriverIsNotWritableException::class);
expect(fn() => $df->updateRecord(0, []))
->toThrow(DriverIsNotWritableException::class);
expect(fn() => $df->removeRecord(0))
expect(fn() => $df->deleteRecord(0))
->toThrow(DriverIsNotWritableException::class);
expect(fn() => $df->insert())
->toThrow(DriverIsNotWritableException::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/DataDrivers/PdoSQL/PdoSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

expect($this->df->getRecordAsArray(2))->toBe(['a' => '4', 'b' => null, 'c' => '6']);

$this->df->removeRecord(2);
$this->df->deleteRecord(2);

expect($this->df->getRecordAsArray(2))->toBe(['a' => '4', 'b' => null, 'c' => '6']);
})->throws(KeyNotExistException::class);
Expand Down

0 comments on commit be44997

Please sign in to comment.