Skip to content

Commit 2977cc4

Browse files
committed
v2.6.3; Bug Fix
1 parent d21b613 commit 2977cc4

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"email": "[email protected]"
1010
}
1111
],
12-
"version": "2.6.2",
12+
"version": "2.6.3",
1313
"require": {
1414
"php": ">=8.1",
1515
"anshu-krishna/php-utilities": "^2.0"

src/ErrorReader.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
<?php
2-
namespace Krishna\DataValidator;
3-
4-
class ErrorReader {
5-
public array $errors = [];
6-
private ?string $_errorstring = null;
7-
public function __construct(array $errors) {
8-
$this->_traverse($errors);
9-
}
10-
private function _traverse(array $a, string $pre = '') {
11-
foreach($a as $k=>$v) {
12-
if(is_array($v)) {
13-
$this->_traverse($v, "{$pre}[${k}]");
14-
} else {
15-
$this->errors[] = "{$pre}[{$k}]: {$v}";
16-
}
17-
}
18-
}
19-
public function __toString() : string {
20-
$this->_errorstring ??= json_encode($this->errors, JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR);
21-
return $this->_errorstring;
22-
}
23-
public function __debugInfo() {
24-
return $this->errors;
25-
}
26-
public function getFormattedErrors(string $seperator = ', ') : string {
27-
return implode($seperator, $this->errors);
28-
}
1+
<?php
2+
namespace Krishna\DataValidator;
3+
4+
class ErrorReader {
5+
public array $errors = [];
6+
private ?string $_errorstring = null;
7+
public function __construct(array $errors) {
8+
$this->_traverse($errors);
9+
}
10+
private function _traverse(array $a, string $pre = '') {
11+
foreach($a as $k=>$v) {
12+
if(is_array($v)) {
13+
$this->_traverse($v, "{$pre}[{$k}]");
14+
} else {
15+
$this->errors[] = "{$pre}[{$k}]: {$v}";
16+
}
17+
}
18+
}
19+
public function __toString() : string {
20+
$this->_errorstring ??= json_encode($this->errors, JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR);
21+
return $this->_errorstring;
22+
}
23+
public function __debugInfo() {
24+
return $this->errors;
25+
}
26+
public function getFormattedErrors(string $seperator = ', ') : string {
27+
return implode($seperator, $this->errors);
28+
}
2929
}

0 commit comments

Comments
 (0)