Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 06f981d

Browse files
authored
Page title (#81)
* Page title * update tests * tests * Update SimpleTest.php * Update SimpleTest.php * Update SimpleTest.php * Update SimpleTest.php * tests * Update SimpleTest.php * Update SimpleTest.php * string only
1 parent c4d2d98 commit 06f981d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/UIKit/Elements/Simple/PageTitle.php

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class PageTitle extends HtmlElement
1414

1515
private $reversed = false;
1616

17+
private $stringOnly = false;
18+
1719
public function __construct(array $titleParts, string $separater = " | ")
1820
{
1921
$this->main = $titleParts;
@@ -33,6 +35,10 @@ public function unfold(): string
3335

3436
$string = implode($this->separater, $this->main);
3537

38+
if ($this->stringOnly) {
39+
return $string;
40+
}
41+
3642
return Html::title($string)->attr(...$this->attributes)->unfold();
3743
}
3844

@@ -41,4 +47,10 @@ public function reversed(): PageTitle
4147
$this->reversed = true;
4248
return $this;
4349
}
50+
51+
public function stringOnly(): PageTitle
52+
{
53+
$this->stringOnly = true;
54+
return $this;
55+
}
4456
}

tests/UIKit/SimpleTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public function page_title()
5959
)->unfoldUsing(
6060
UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()
6161
);
62+
63+
AssertEquals::applyWith(
64+
'How are you? : Hello, World!',
65+
"string",
66+
1.95, // 1.82, // 0.91, // 0.71, // 0.6,
67+
3
68+
)->unfoldUsing(
69+
UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()->stringOnly()
70+
);
6271
}
6372

6473
/**

0 commit comments

Comments
 (0)