Skip to content

Commit

Permalink
chore: ensure title and keywords are casted as strings, handle except…
Browse files Browse the repository at this point in the history
…ions gracefully within the preview
  • Loading branch information
wilr committed Sep 17, 2024
1 parent ec7ea1d commit d7a3717
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Analysis/TitleAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function responses()
return [
static::TITLE_IS_HOME => [
'The page title should be changed from "Home"; ' .
'that title almost always reduces click-through rate. ' .
'Please retain "Home" as the Navigation Label, however.',
'that title almost always reduces click-through rate. ' .
'Please retain "Home" as the Navigation Label, however.',
'danger'
],
static::TITLE_TOO_SHORT => ['The page title is too short', 'danger'],
Expand All @@ -37,7 +37,7 @@ public function responses()
static::TITLE_NO_FOCUS_KEYWORD => ['The page title does not contain the focus keyword', 'warning'],
static::TITLE_FOCUS_KEYWORD_POSITION => [
'The page title contains the focus keyword but is not at the beginning; ' .
'consider moving it to the beginning',
'consider moving it to the beginning',
'warning'
],
static::TITLE_SUCCESS => [
Expand All @@ -55,8 +55,8 @@ public function responses()
*/
public function run()
{
$title = $this->getPage()->Title;
$keyword = $this->getPage()->FocusKeyword;
$title = (string) $this->getPage()->Title;
$keyword = (string) $this->getPage()->FocusKeyword;

if (strtolower($title) == 'home') {
return static::TITLE_IS_HOME;
Expand Down
14 changes: 13 additions & 1 deletion src/Forms/HealthAnalysisField.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,19 @@ public function runAnalyses()
foreach ($analyses as $analysisClass) {
/** @var Analysis $analysis */
$analysis = $analysisClass::create($this->getPage());
$output->push($analysis->inspect());
try {
$output->push($analysis->inspect());
} catch (\Exception $e) {
$output->push(
ArrayData::create(
[
'Title' => 'Error',
'Message' => $e->getMessage(),
'Type' => 'danger',
]
)
);
}
}

return $output;
Expand Down

0 comments on commit d7a3717

Please sign in to comment.