Skip to content

Commit bab9395

Browse files
author
Antoine Aflalo
committed
feat(argument): Change how glue is defined
For the mergeable argument. BREAKING CHANGE: IMergeableArgument::glue() is now static.
1 parent f014a72 commit bab9395

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/Request/Api/BaseRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function addArgument(IArgument $arg): IRequest
6060
{
6161
if ($arg instanceof IMergeableArgument) {
6262
if (!isset($this->mergeableArguments[$arg->getKey()])) {
63-
$this->mergeableArguments[$arg->getKey()] = new ArgMerger();
63+
$this->mergeableArguments[$arg->getKey()] = new ArgMerger($arg::glue());
6464
}
6565

6666
$this->mergeableArguments[$arg->getKey()]->addArgument($arg);

src/Request/Arguments/Mergeable/ArgMerger.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,28 @@
1212

1313
class ArgMerger implements PrimalValued
1414
{
15+
16+
/**
17+
* @var string
18+
*/
19+
private $glue;
20+
21+
1522
/**
1623
* @var IMergeableArgument[]
1724
*/
1825
private $args = [];
1926

27+
/**
28+
* ArgMerger constructor.
29+
*
30+
* @param string $glue
31+
*/
32+
public function __construct(string $glue)
33+
{
34+
$this->glue = $glue;
35+
}
36+
2037
/**
2138
* Add the argument.
2239
*
@@ -58,7 +75,7 @@ public function toPrimitive()
5875

5976
$values = array_keys($this->args);
6077

61-
return implode($this->args[$values[0]]->glue(), $values);
78+
return implode($this->glue, $values);
6279
}
6380

6481
/**

src/Request/Arguments/Mergeable/IMergeableArgument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ interface IMergeableArgument extends IArgument
2424
*
2525
* @return string
2626
*/
27-
public function glue();
27+
public static function glue();
2828
}

tests/src/Base/Argument/TestMergeableArg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getKey(): string
4242
*
4343
* @return string
4444
*/
45-
public function glue()
45+
public static function glue()
4646
{
4747
return ';';
4848
}

0 commit comments

Comments
 (0)