Skip to content

Commit 27b9156

Browse files
committed
Add immutable setters
1 parent 668e96f commit 27b9156

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Request.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ private function resolveRequestStream(StreamInterface|array|string|null $body):
164164
public function getCliKeyword(): ?string
165165
{
166166
if ($this->cliKeywords === null) {
167+
167168
$new = [];
168169
$arg = $this->getUri()->getArgv();
169170
foreach ($arg as $val) {
@@ -182,6 +183,19 @@ public function getCliKeyword(): ?string
182183
return $this->cliKeywords;
183184
}
184185

186+
/**
187+
* With new CLI keyword
188+
*
189+
* @param string $cliKeywords
190+
* @return $this
191+
*/
192+
public function withCliKeyword(string $cliKeywords): self
193+
{
194+
$inst = clone $this;
195+
$inst->cliKeywords = trim($cliKeywords);
196+
return $inst;
197+
}
198+
185199
/**
186200
* Get Cli arguments
187201
* @return array

Uri.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getScheme(): string
9292

9393
/**
9494
* Get dir
95-
* @return string (ex: http/https)
95+
* @return string
9696
*/
9797
public function getDir(): string
9898
{
@@ -102,6 +102,19 @@ public function getDir(): string
102102
return (string)$this->encoded['dir'];
103103
}
104104

105+
/**
106+
* With new DIR
107+
*
108+
* @param string $dir
109+
* @return $this
110+
*/
111+
public function withDir(string $dir): self
112+
{
113+
$inst = clone $this;
114+
$inst->setPart("dir", $dir);
115+
return $inst;
116+
}
117+
105118
/**
106119
* Get dir
107120
* @return string (ex: http/https)

0 commit comments

Comments
 (0)