forked from php-embed/Embed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthorUrl.php
More file actions
28 lines (23 loc) · 792 Bytes
/
AuthorUrl.php
File metadata and controls
28 lines (23 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types = 1);
namespace Embed\Adapters\Gist\Detectors;
use Embed\Detectors\AuthorUrl as Detector;
use Psr\Http\Message\UriInterface;
/**
* @extends Detector<\Embed\Adapters\Gist\Extractor>
*/
class AuthorUrl extends Detector
{
public function detect(): ?UriInterface
{
$extractor = $this->extractor;
$api = $extractor->getApi();
$owner = $api->str('owner');
// Exclude empty string and '0' to maintain original truthy check behavior
// The string '0' is not a valid GitHub username and should not generate a URL
if (is_string($owner) && $owner !== '' && $owner !== '0') {
return $extractor->getCrawler()->createUri("https://github.com/{$owner}");
}
return parent::detect();
}
}