Skip to content

Commit

Permalink
commit update / updateValue and prepareReturnValue
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzylka committed Jan 13, 2023
1 parent e61795c commit 5ad7763
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Trait/TableHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ trait TableHelpers {

/**
* Prepare return data
* @param array $data
* @param false|array $data
* @return array
*/
private function prepareReturnValue(array $data) : array {
private function prepareReturnValue(false|array $data) : array {
if (!$data) {
return [];
}

$returnData = [];

if (isset(array_keys($data)[0]) && is_int(array_keys($data)[0])) {
Expand Down
6 changes: 5 additions & 1 deletion src/Trait/TableUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ trait TableUpdate {
*/
public function update(array $data) : bool {
if (is_null($this->getName())) {
throw new UpdateException('Id is not defined');
throw new UpdateException('Table is not defined');
} elseif (is_null($this->getId())) {
throw new UpdateException('ID is not defined');
}

$set = [];
Expand Down Expand Up @@ -49,6 +51,8 @@ public function update(array $data) : bool {
*/
public function updateValue(string $columnName, mixed $value) : bool {
if (is_null($this->getName())) {
throw new UpdateException('Table is not defined');
} elseif (is_null($this->getId())) {
throw new UpdateException('ID is not defined');
}

Expand Down

0 comments on commit 5ad7763

Please sign in to comment.