Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach authored and github-actions[bot] committed Sep 23, 2024
1 parent 5124943 commit a6b7ec1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/Robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class Robots
{
protected RobotsTxt | null $robotsTxt;
protected ?RobotsTxt $robotsTxt;

public function __construct(
protected string | null $userAgent = null,
RobotsTxt | string | null $source = null,
protected ?string $userAgent = null,
RobotsTxt|string|null $source = null,
) {
if ($source instanceof RobotsTxt) {
$this->robotsTxt = $source;
Expand All @@ -21,7 +21,7 @@ public function __construct(
}
}

public function withTxt(RobotsTxt | string $source): self
public function withTxt(RobotsTxt|string $source): self
{
$this->robotsTxt = $source instanceof RobotsTxt
? $source
Expand All @@ -30,12 +30,12 @@ public function withTxt(RobotsTxt | string $source): self
return $this;
}

public static function create(string $userAgent = null, string $source = null): self
public static function create(?string $userAgent = null, ?string $source = null): self
{
return new self($userAgent, $source);
}

public function mayIndex(string $url, string $userAgent = null): bool
public function mayIndex(string $url, ?string $userAgent = null): bool
{
$userAgent = $userAgent ?? $this->userAgent;

Expand Down
4 changes: 2 additions & 2 deletions src/RobotsHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function mayIndex(string $userAgent = '*'): bool

public function mayFollow(string $userAgent = '*'): bool
{
return $this->none($userAgent) ? false : ! $this->nofollow($userAgent);
return $this->none($userAgent) ? false : ! $this->nofollow($userAgent);
}

public function noindex(string $userAgent = '*'): bool
Expand All @@ -57,7 +57,7 @@ public function nofollow(string $userAgent = '*'): bool

public function none(string $userAgent = '*'): bool
{
return
return
$this->robotHeadersProperties[$userAgent]['none']
?? $this->robotHeadersProperties['*']['none']
?? false;
Expand Down
2 changes: 1 addition & 1 deletion src/RobotsMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function nofollow(): bool
return $this->robotsMetaTagProperties['nofollow'] ?? false;
}

#[ArrayShape(['noindex' => "bool", 'nofollow' => "bool"])]
#[ArrayShape(['noindex' => 'bool', 'nofollow' => 'bool'])]
protected function findRobotsMetaTagProperties(string $html): array
{
$metaTagLine = $this->findRobotsMetaTagLine($html);
Expand Down
8 changes: 4 additions & 4 deletions src/RobotsTxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function create(string $source): self
return new self($source);
}

public function allows(string $url, string | null $userAgent = '*'): bool
public function allows(string $url, ?string $userAgent = '*'): bool
{
$requestUri = '';

Expand All @@ -83,11 +83,11 @@ public function allows(string $url, string | null $userAgent = '*'): bool
}

$disallowsPerUserAgent = $this->includeGlobalGroup
? $this->disallowsPerUserAgent
? $this->disallowsPerUserAgent
: array_filter($this->disallowsPerUserAgent, fn ($key) => $key !== '*', ARRAY_FILTER_USE_KEY);

$normalizedUserAgent = strtolower(trim($userAgent ?? ''));

$disallows = $this->matchExactly
? $this->getDisallowsExactly($normalizedUserAgent, $disallowsPerUserAgent)
: $this->getDisallowsContaining($normalizedUserAgent, $disallowsPerUserAgent);
Expand Down
4 changes: 2 additions & 2 deletions tests/RobotsTxtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function test_allowed_link_for_custom_user_agent()
$robots = RobotsTxt::readFrom(__DIR__.'/data/robots.txt');

$this->assertFalse($robots->allows('/test', 'google'));

$this->assertTrue($robots
->exactMatchesOnly()
->allows('/no-agents', 'Mozilla/5.0 (compatible; UserAgent007/1.1)')
Expand All @@ -61,7 +61,7 @@ public function test_allowed_link_for_custom_user_agent()
->withPartialMatches()
->allows('/no-agents', 'Mozilla/5.0 (compatible; UserAgent007/1.1)')
);

$this->assertTrue($robots
->ignoreGlobalGroup()
->withPartialMatches()
Expand Down

0 comments on commit a6b7ec1

Please sign in to comment.