-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from resohead/sitemap
support sitemap report
- Loading branch information
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace OhDear\PhpSdk\Actions; | ||
|
||
use OhDear\PhpSdk\Resources\SitemapResult; | ||
use OhDear\PhpSdk\Resources\SitemapIndex; | ||
use OhDear\PhpSdk\Resources\SitemapIssue; | ||
use OhDear\PhpSdk\Resources\Sitemap; | ||
|
||
trait ManagesSitemaps | ||
{ | ||
public function sitemap(int $siteId) | ||
{ | ||
$response = $this->get("sitemap/{$siteId}") ?? []; | ||
|
||
$issues = $this->transformCollection($response['issues'], SitemapIssue::class); | ||
$sitemapIndexes = $this->transformCollection($response['sitemapIndexes'], SitemapIndex::class); | ||
$sitemaps = $this->transformCollection($response['sitemaps'], Sitemap::class); | ||
|
||
$response['issues'] = $issues; | ||
$response['sitemapIndexes'] = $sitemapIndexes; | ||
$response['sitemaps'] = $sitemaps; | ||
|
||
return new SitemapResult($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace OhDear\PhpSdk\Resources; | ||
|
||
class Sitemap extends ApiResource | ||
{ | ||
public string $url; | ||
|
||
public int $urlCount; | ||
|
||
public bool $checkedReachabilityOfAllUrls; | ||
|
||
public int $issuesCount; | ||
|
||
/** | ||
* @var array<SitemapIssue> | ||
*/ | ||
public array $issues; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace OhDear\PhpSdk\Resources; | ||
|
||
class SitemapIndex extends ApiResource | ||
{ | ||
public string $url; | ||
|
||
/** | ||
* @var array<SitemapIssue> | ||
*/ | ||
public array $issues; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace OhDear\PhpSdk\Resources; | ||
|
||
class SitemapIssue extends ApiResource | ||
{ | ||
public string $name; | ||
|
||
public ?string $url; | ||
|
||
public ?int $responseCode; | ||
|
||
public function __construct(mixed $attributes, $ohDear = null) | ||
{ | ||
parent::__construct($attributes, $ohDear); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace OhDear\PhpSdk\Resources; | ||
|
||
class SitemapResult extends ApiResource | ||
{ | ||
/* | ||
* The url that is checked. | ||
*/ | ||
public string $checkUrl; | ||
|
||
/* | ||
* The total number of issues found. | ||
*/ | ||
public int $totalIssuesCount; | ||
|
||
/* | ||
* The total number of urls found. | ||
*/ | ||
public int $totalUrlCount; | ||
|
||
/* | ||
* Whether there are issues found. | ||
*/ | ||
public bool $hasIssues; | ||
|
||
/* | ||
* A list of issues found. | ||
* @return array<int, SitemapIssue> | ||
*/ | ||
public array $issues; | ||
|
||
/* | ||
* The sitemap indexes found along with any issues. | ||
* @return array<int, SitemapIndex> | ||
*/ | ||
public array $sitemapIndexes; | ||
|
||
/* | ||
* The sitemaps found. | ||
* @return array<int, Sitemap> | ||
*/ | ||
public array $sitemaps; | ||
|
||
public function __construct(mixed $attributes, $ohDear = null) | ||
{ | ||
parent::__construct($attributes, $ohDear); | ||
} | ||
} |