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
27 lines (22 loc) · 807 Bytes
/
AuthorUrl.php
File metadata and controls
27 lines (22 loc) · 807 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
<?php
declare(strict_types = 1);
namespace Embed\Adapters\Gist\Detectors;
use Embed\Adapters\Gist\Extractor;
use Embed\Detectors\AuthorUrl as Detector;
use Psr\Http\Message\UriInterface;
class AuthorUrl extends Detector
{
public function detect(): ?UriInterface
{
/** @var Extractor $extractor */
$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();
}
}