Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/UIKit/Elements/Simple/PageTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class PageTitle extends HtmlElement

private $reversed = false;

private $stringOnly = false;

public function __construct(array $titleParts, string $separater = " | ")
{
$this->main = $titleParts;
Expand All @@ -33,6 +35,10 @@ public function unfold(): string

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

if ($this->stringOnly) {
return $string;
}

return Html::title($string)->attr(...$this->attributes)->unfold();
}

Expand All @@ -41,4 +47,10 @@ public function reversed(): PageTitle
$this->reversed = true;
return $this;
}

public function stringOnly(): PageTitle
{
$this->stringOnly = true;
return $this;
}
}
9 changes: 9 additions & 0 deletions tests/UIKit/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public function page_title()
)->unfoldUsing(
UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()
);

AssertEquals::applyWith(
'How are you? : Hello, World!',
"string",
1.95, // 1.82, // 0.91, // 0.71, // 0.6,
3
)->unfoldUsing(
UIKit::pageTitle(["Hello, World!", "How are you?"], " : ")->reversed()->stringOnly()
);
}

/**
Expand Down