Skip to content

Commit a3827cf

Browse files
committedApr 1, 2016
working on formatting
1 parent 3ba06ad commit a3827cf

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎src/Illuminate/Validation/Validator.php

+13-9
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ public function each($attribute, $rules)
323323
*/
324324
protected function initializeAttributeOnData($attribute)
325325
{
326-
$explicitAddress = $this->getExplicitAddress($attribute);
326+
$explicitPath = $this->getLeadingExplicitAttributePath($attribute);
327327

328-
$data = $this->extractData($explicitAddress);
328+
$data = $this->extractDataFromPath($explicitPath);
329329

330330
if (! Str::contains($attribute, '*') || Str::endsWith($attribute, '*')) {
331331
return $data;
@@ -895,9 +895,9 @@ protected function validateInArray($attribute, $value, $parameters)
895895
{
896896
$this->requireParameterCount(1, $parameters, 'in_array');
897897

898-
$explicitAddress = $this->getExplicitAddress($parameters[0]);
898+
$explicitPath = $this->getLeadingExplicitAttributePath($parameters[0]);
899899

900-
$attributeData = $this->extractData($explicitAddress);
900+
$attributeData = $this->extractDataFromPath($explicitPath);
901901

902902
$otherValues = Arr::where(Arr::dot($attributeData), function ($key) use ($parameters) {
903903
return Str::is($parameters[0], $key);
@@ -1236,9 +1236,9 @@ protected function validateDistinct($attribute, $value, $parameters)
12361236
{
12371237
$attributeName = $this->getPrimaryAttribute($attribute);
12381238

1239-
$explicitAddress = $this->getExplicitAddress($attributeName);
1239+
$explicitPath = $this->getLeadingExplicitAttributePath($attributeName);
12401240

1241-
$attributeData = $this->extractData($explicitAddress);
1241+
$attributeData = $this->extractDataFromPath($explicitPath);
12421242

12431243
$data = Arr::where(Arr::dot($attributeData), function ($key) use ($attribute, $attributeName) {
12441244
return $key != $attribute && Str::is($attributeName, $key);
@@ -2580,21 +2580,25 @@ protected function getNumericKeys($attribute)
25802580
*
25812581
* E.g. 'foo.bar.*.baz' -> 'foo.bar'
25822582
*
2583+
* Allows us to not spin through all of the flattened data for some operations.
2584+
*
25832585
* @param string $attribute
25842586
* @return string
25852587
*/
2586-
protected function getExplicitAddress($attribute)
2588+
protected function getLeadingExplicitAttributePath($attribute)
25872589
{
25882590
return rtrim(explode('*', $attribute)[0], '.');
25892591
}
25902592

25912593
/**
2592-
* Extract only the given attribute's values from the data.
2594+
* Extract data based on the given dot-notated path.
2595+
*
2596+
* Used to extract a sub-section of the data for faster iteration.
25932597
*
25942598
* @param string $attribute
25952599
* @return array
25962600
*/
2597-
protected function extractData($attribute)
2601+
protected function extractDataFromPath($attribute)
25982602
{
25992603
$results = [];
26002604

0 commit comments

Comments
 (0)
Please sign in to comment.