Skip to content

Commit 84d1172

Browse files
authored
Merge pull request #15 from 8fold/forms
Add page title
2 parents 7ab381a + c3f6aa4 commit 84d1172

File tree

4 files changed

+84
-45
lines changed

4 files changed

+84
-45
lines changed

composer.lock

Lines changed: 37 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@
66
colors="true"
77
processIsolation="false"
88
stopOnFailure="false"
9-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
10-
backupStaticProperties="false">
11-
<coverage>
12-
<include>
13-
<directory suffix=".php">./src/</directory>
14-
</include>
15-
<exclude>
16-
<directory>vendor/</directory>
17-
</exclude>
18-
</coverage>
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" backupStaticProperties="false">
10+
<coverage/>
1911
<testsuites>
2012
<testsuite name="base">
2113
<directory suffix="Test.php">./tests/</directory>
@@ -25,4 +17,12 @@
2517
<ini name="display_errors" value="On"/>
2618
<ini name="display_startup_errors" value="On"/>
2719
</php>
20+
<source>
21+
<include>
22+
<directory suffix=".php">./src/</directory>
23+
</include>
24+
<exclude>
25+
<directory>vendor/</directory>
26+
</exclude>
27+
</source>
2828
</phpunit>

src/Components/PageTitle.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Eightfold\HTMLBuilder\Components;
5+
6+
use Stringable;
7+
8+
use Eightfold\HTMLBuilder\Element;
9+
10+
class PageTitle implements Stringable
11+
{
12+
/**
13+
* @param string[] $titles
14+
*/
15+
public static function create(array $titles, string $separator = ' | '): self
16+
{
17+
return new self($titles, $separator);
18+
}
19+
20+
/**
21+
* @param string[] $titles
22+
*/
23+
final private function __construct(
24+
private array $titles,
25+
private readonly string $separator
26+
) {
27+
}
28+
29+
public function __toString(): string
30+
{
31+
return (string) Element::title(
32+
implode($this->separator, $this->titles)
33+
);
34+
}
35+
}

src/Forms/Select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function selectDropdown(): Element
125125
{
126126
$elements = [];
127127
foreach ($this->options as $value => $content) {
128-
$value = strval($value);
128+
$value = (string) $value;
129129
$option = Element::option($content)->props('value ' . $value);
130130
if ($this->isSelected($value)) {
131131
$option = $option->prop('selected selected');
@@ -151,7 +151,7 @@ private function selectOther(): Element
151151
$type = 'checkbox';
152152
}
153153
foreach ($this->options as $value => $content) {
154-
$value = strval($value);
154+
$value = (string) $value;
155155
$id = $this->name . '-' . $value;
156156
$label = Element::label($content)->props('for ' . $id);
157157
$input = Element::input()->omitEndTag()->props(

0 commit comments

Comments
 (0)