Skip to content

Commit 644e348

Browse files
committed
rename methods
1 parent ce73ff3 commit 644e348

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/behaviors/JsonAttributeBehavior.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ class JsonAttributeBehavior extends AttributeBehavior
5555
public function events(): array
5656
{
5757
return [
58-
Model::EVENT_BEFORE_VALIDATE => 'beforeValidate',
59-
Model::EVENT_AFTER_VALIDATE => 'afterValidate'
58+
Model::EVENT_BEFORE_VALIDATE => 'ensureValueIsArray',
59+
Model::EVENT_AFTER_VALIDATE => 'convertBackToOriginalTypeIfNeeded'
6060
];
6161
}
6262

6363
/**
6464
* Ensure that the attribute value is an array if it is a string.
6565
*/
66-
public function beforeValidate(): void
66+
public function ensureValueIsArray(): void
6767
{
6868
foreach ($this->attributes as $attribute) {
6969
if (is_string($this->owner->$attribute)) {
@@ -83,7 +83,7 @@ public function beforeValidate(): void
8383
/**
8484
* Ensure that the attribute will be converted back to its original type if an error occurs.
8585
*/
86-
public function afterValidate(): void
86+
public function convertBackToOriginalTypeIfNeeded(): void
8787
{
8888
if ($this->owner->hasErrors() || $this->alwaysConvertBackToOriginalType) {
8989
foreach ($this->attributes as $attribute) {

tests/phpunit.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
3-
<source>
4-
<include>
5-
<directory>../src/</directory>
6-
</include>
7-
</source>
83
</phpunit>

0 commit comments

Comments
 (0)