Skip to content

Commit 4c5b11b

Browse files
committed
Refactor ModelObserver
1 parent 2269286 commit 4c5b11b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ModelObserver.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ public function __construct(DynamoDbClientInterface $dynamoDb)
3232
$this->attributeFilter = $dynamoDb->getAttributeFilter();
3333
}
3434

35-
protected function _save($model)
35+
private function saveToDynamoDb($model)
3636
{
3737
$attrs = $model->attributesToArray();
38-
// $this->attributeFilter->filter($attrs);
38+
3939
try {
4040
$this->dynamoDbClient->putItem([
4141
'TableName' => $model->getDynamoDbTableName(),
4242
'Item' => $this->marshaler->marshalItem($attrs),
4343
]);
4444
} catch (Exception $e) {
45-
Log::info($e);
45+
Log::error($e);
4646
}
4747
}
4848

49-
protected function _delete($model)
49+
private function deleteFromDynamoDb($model)
5050
{
5151
$key = [$model->getKeyName() => $model->getKey()];
5252

@@ -56,27 +56,27 @@ protected function _delete($model)
5656
'Key' => $this->marshaler->marshalItem($key),
5757
]);
5858
} catch (Exception $e) {
59-
Log::info($e);
59+
Log::error($e);
6060
}
6161
}
6262

6363
public function created($model)
6464
{
65-
$this->_save($model);
65+
$this->saveToDynamoDb($model);
6666
}
6767

6868
public function updated($model)
6969
{
70-
$this->_save($model);
70+
$this->saveToDynamoDb($model);
7171
}
7272

7373
public function deleted($model)
7474
{
75-
$this->_delete($model);
75+
$this->deleteFromDynamoDb($model);
7676
}
7777

7878
public function restored($model)
7979
{
80-
$this->_save($model);
80+
$this->saveToDynamoDb($model);
8181
}
8282
}

0 commit comments

Comments
 (0)