Skip to content

Commit 7ec621d

Browse files
Merge pull request #4 from theriddleofenigma/analysis-qxopd0
Apply fixes from StyleCI
2 parents 8d9e654 + b84fa16 commit 7ec621d

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

src/ModelValidator.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
use Illuminate\Support\Facades\Validator;
66

77
/**
8-
* Class ModelValidator
9-
*
10-
* @package App\Packages
8+
* Class ModelValidator.
119
*/
1210
class ModelValidator
1311
{
1412
/**
15-
* The model object to validate
13+
* The model object to validate.
1614
*
1715
* @var
1816
*/
@@ -40,7 +38,7 @@ class ModelValidator
4038
protected $customAttributes = [];
4139

4240
/**
43-
* ModelValidator constructor
41+
* ModelValidator constructor.
4442
*
4543
* @param $model
4644
*/
@@ -51,7 +49,7 @@ public function __construct($model)
5149
}
5250

5351
/**
54-
* Initialize this class by setting up the needed params
52+
* Initialize this class by setting up the needed params.
5553
*
5654
* @return $this
5755
*/
@@ -73,7 +71,7 @@ public function initialize()
7371
}
7472

7573
/**
76-
* Validate the model params
74+
* Validate the model params.
7775
*
7876
* @return $this
7977
*/

src/ValidatorTrait.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,40 @@ trait ValidatorTrait
66
{
77
/**
88
* Calls the validator instance to validate
9-
* Also runs the beforeValidation and afterValidation methods if exists
9+
* Also runs the beforeValidation and afterValidation methods if exists.
1010
*/
1111
public function validate()
1212
{
1313
// Runs the logic that might be executed before the model validation
14-
if (method_exists($this, 'beforeValidation')) $this->beforeValidation();
14+
if (method_exists($this, 'beforeValidation')) {
15+
$this->beforeValidation();
16+
}
1517

1618
// Model validation
1719
(new ModelValidator($this))->validate();
1820

1921
// Runs the logic that might be executed after the model validation
20-
if (method_exists($this, 'afterValidation')) $this->afterValidation();
22+
if (method_exists($this, 'afterValidation')) {
23+
$this->afterValidation();
24+
}
2125
}
22-
26+
2327
/**
24-
* Alias method for calling the validate method on saving the model
28+
* Alias method for calling the validate method on saving the model.
2529
*/
26-
public static function validateOnSaving() {
27-
static::saving(function($model){
30+
public static function validateOnSaving()
31+
{
32+
static::saving(function ($model) {
2833
$model->validate();
2934
});
3035
}
3136

3237
/**
33-
* Alias method for calling the validate method on creating the model
38+
* Alias method for calling the validate method on creating the model.
3439
*/
35-
public static function validateOnCreating() {
36-
static::creating(function($model){
40+
public static function validateOnCreating()
41+
{
42+
static::creating(function ($model) {
3743
$model->validate();
3844
});
3945
}

0 commit comments

Comments
 (0)