Skip to content

Commit 604b68b

Browse files
committed
Add info_contents option
1 parent 09553bd commit 604b68b

File tree

3 files changed

+9
-66
lines changed

3 files changed

+9
-66
lines changed

.phpstorm.meta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
'debugger_options',
117117
'color',
118118
'icon_path',
119-
'info_link',
119+
'info_contents',
120120
);
121121
expectedArguments(
122122
\Framework\Debug\Debugger::getOption(),

src/Views/debugbar/debugbar.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
* @var array<string,mixed> $options
99
*/
1010
$infoIcon = file_get_contents(__DIR__ . '/icons/info.svg');
11-
$hasInfoLink = isset($options['info_link']);
12-
if ($hasInfoLink) {
13-
if (!isset($options['info_link']['href']) || !isset($options['info_link']['text'])) {
14-
throw new LogicException('Info link must contain "href" and "text" keys');
15-
}
11+
if (!isset($options['info_contents'])) {
12+
$options['info_contents'] = '<p>★ <a href="https://aplus-framework.com" target="_blank">aplus-framework.com</a></p>';
1613
}
1714
$iconPath = __DIR__ . '/icon.png';
1815
if (isset($options['icon_path'])) {
@@ -50,15 +47,7 @@ class_exists('Aplus')
5047
: '' ?> on <?= \PHP_OS_FAMILY ?> with PHP
5148
<?= Debugger::roundVersion(\PHP_VERSION) ?>.
5249
</p>
53-
<p>★
54-
<?php if ($hasInfoLink): ?>
55-
<a href="<?= htmlentities($options['info_link']['href']) ?>"
56-
target="_blank"><?= htmlentities($options['info_link']['text']) ?>
57-
</a>
58-
<?php else: ?>
59-
<a href="https://aplus-framework.com" target="_blank">aplus-framework.com</a>
60-
<?php endif ?>
61-
</p>
50+
<?= $options['info_contents'] ?>
6251
<?php
6352
$count = isset($activities['collected']) ? count($activities['collected']) : 0;
6453
if ($count):

tests/DebuggerTest.php

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -233,60 +233,14 @@ public function testInvalidIconPathOption() : void
233233
$this->closeBuffer();
234234
}
235235

236-
public function testInfoLinkOption() : void
236+
public function testInfoContentsOption() : void
237237
{
238-
$this->debugger->setOption('info_link', [
239-
'href' => 'https://foo.com',
240-
'text' => 'Foo Website',
241-
]);
242238
$debugbar = $this->debugger->renderDebugbar();
243-
self::assertStringContainsString('https://foo.com', $debugbar);
244-
self::assertStringContainsString('Foo Website', $debugbar);
245-
}
246-
247-
public function testInvalidInfoLinkOption() : void
248-
{
249-
$this->debugger->setOption('info_link', []);
250-
try {
251-
$this->debugger->renderDebugbar();
252-
} catch (\LogicException $e) {
253-
self::assertSame(
254-
'Info link must contain "href" and "text" keys',
255-
$e->getMessage()
256-
);
257-
}
258-
$this->closeBuffer();
259-
$this->debugger->setOption('info_link', [
260-
'href' => '#',
261-
]);
262-
try {
263-
$this->debugger->renderDebugbar();
264-
} catch (\LogicException $e) {
265-
self::assertSame(
266-
'Info link must contain "href" and "text" keys',
267-
$e->getMessage()
268-
);
269-
}
270-
$this->closeBuffer();
271-
$this->debugger->setOption('info_link', [
272-
'text' => '#',
273-
]);
274-
try {
275-
$this->debugger->renderDebugbar();
276-
} catch (\LogicException $e) {
277-
self::assertSame(
278-
'Info link must contain "href" and "text" keys',
279-
$e->getMessage()
280-
);
281-
}
282-
$this->closeBuffer();
283-
$this->debugger->setOption('info_link', [
284-
'href' => 'https://foo.com',
285-
'text' => 'Foo Website',
286-
]);
239+
self::assertStringContainsString('', $debugbar);
240+
$this->debugger->setOption('info_contents', 'xxXxx');
287241
$debugbar = $this->debugger->renderDebugbar();
288-
self::assertStringContainsString('https://foo.com', $debugbar);
289-
self::assertStringContainsString('Foo Website', $debugbar);
242+
self::assertStringContainsString('xxXxx', $debugbar);
243+
self::assertStringNotContainsString('', $debugbar);
290244
}
291245

292246
public function testMakeSafeName() : void

0 commit comments

Comments
 (0)