Skip to content

Commit 888670d

Browse files
committed
Add helper method for HeaderBlock
1 parent fe06f97 commit 888670d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Block/HeaderBlock.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ public function __construct(
1616
) {
1717
parent::__construct($id);
1818
}
19+
20+
/**
21+
* This is a helper method to get the HTML tag for the header
22+
*/
23+
public function getTag(): string
24+
{
25+
return sprintf('h%d', $this->level);
26+
}
1927
}

tests/Block/HeaderBlockTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66

77
final class HeaderBlockTest extends BlockTestCase
88
{
9-
protected function getBlock(): Block
9+
protected function getBlock(): HeaderBlock
1010
{
1111
return new HeaderBlock('id', 'Header', 1);
1212
}
13+
14+
/**
15+
* @test
16+
*/
17+
public function it_returns_tag(): void
18+
{
19+
self::assertSame('h1', $this->getBlock()->getTag());
20+
}
1321
}

0 commit comments

Comments
 (0)