Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda677dc

Browse files
committed
Improve attribute class
1 parenta782e34 commitda677dc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎src/Lodash/Testing/Attributes.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
class Attributesimplements Arrayable
1616
{
17-
privateconstRELATION_MARKER ='relations:';
17+
privateconststringRELATION_MARKER ='relations:';
18+
privateconststringDYNAMIC_COUNT_MARKER ='*';
1819
privatearray$params;
1920
privatearray$attributes = [];
2021
/** @var array<self> */
@@ -97,7 +98,7 @@ private function parseParameters(array $params): void
9798
$attributes = [];
9899
$relations = [];
99100
foreach ($paramsas$key =>$data) {
100-
if (str_starts_with($key,self::RELATION_MARKER)) {
101+
if (str_starts_with((string)$key,self::RELATION_MARKER)) {
101102
$ex =explode(':',$key);
102103
if (!isset($ex[1])) {
103104
thrownewInvalidArgumentException('Relation is empty');
@@ -106,9 +107,9 @@ private function parseParameters(array $params): void
106107
$relName =$ex[1];
107108
$count =1;
108109
if (isset($ex[2])) {
109-
$count = (int)$ex[2];
110+
$count =$ex[2] ===self::DYNAMIC_COUNT_MARKER ?count($data) :(int)$ex[2];
110111
}
111-
$attrs =$params[$key];
112+
$attrs =$data;
112113

113114
$relations[$relName] =newself($attrs,$relName,$count);
114115
}else {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp