Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Resonance
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
distantmagic
Resonance
Commits
1613261b
Commit
1613261b
authored
1 year ago
by
Mateusz Charytoniuk
Browse files
Options
Downloads
Patches
Plain Diff
chore: stricter static pages types
parent
4c25116d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/StaticPage.php
+20
-1
20 additions, 1 deletion
src/StaticPage.php
with
20 additions
and
1 deletion
src/StaticPage.php
+
20
−
1
View file @
1613261b
...
@@ -5,6 +5,7 @@ declare(strict_types=1);
...
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace
Distantmagic\Resonance
;
namespace
Distantmagic\Resonance
;
use
Distantmagic\Resonance\InputValidatedData\FrontMatter
;
use
Distantmagic\Resonance\InputValidatedData\FrontMatter
;
use
RuntimeException
;
use
Symfony\Component\Finder\SplFileInfo
;
use
Symfony\Component\Finder\SplFileInfo
;
readonly
class
StaticPage
readonly
class
StaticPage
...
@@ -25,12 +26,21 @@ readonly class StaticPage
...
@@ -25,12 +26,21 @@ readonly class StaticPage
return
mb_strtolower
(
$this
->
frontMatter
->
title
)
<=>
mb_strtolower
(
$other
->
frontMatter
->
title
);
return
mb_strtolower
(
$this
->
frontMatter
->
title
)
<=>
mb_strtolower
(
$other
->
frontMatter
->
title
);
}
}
/**
* @return non-empty-string
*/
public
function
getBasename
():
string
public
function
getBasename
():
string
{
{
$relativePath
=
$this
->
file
->
getRelativePath
();
$relativePath
=
$this
->
file
->
getRelativePath
();
if
(
empty
(
$relativePath
))
{
if
(
empty
(
$relativePath
))
{
return
$this
->
file
->
getFilenameWithoutExtension
();
$filename
=
$this
->
file
->
getFilenameWithoutExtension
();
if
(
empty
(
$filename
))
{
throw
new
RuntimeException
(
'Unable to determine filename'
);
}
return
$filename
;
}
}
return
sprintf
(
return
sprintf
(
...
@@ -40,6 +50,9 @@ readonly class StaticPage
...
@@ -40,6 +50,9 @@ readonly class StaticPage
);
);
}
}
/**
* @return non-empty-string
*/
public
function
getHref
():
string
public
function
getHref
():
string
{
{
if
(
'index'
===
$this
->
file
->
getFilenameWithoutExtension
())
{
if
(
'index'
===
$this
->
file
->
getFilenameWithoutExtension
())
{
...
@@ -55,6 +68,9 @@ readonly class StaticPage
...
@@ -55,6 +68,9 @@ readonly class StaticPage
return
'/'
.
$this
->
getBasename
()
.
'.html'
;
return
'/'
.
$this
->
getBasename
()
.
'.html'
;
}
}
/**
* @return non-empty-string
*/
public
function
getOutputDirectory
():
string
public
function
getOutputDirectory
():
string
{
{
return
sprintf
(
return
sprintf
(
...
@@ -64,6 +80,9 @@ readonly class StaticPage
...
@@ -64,6 +80,9 @@ readonly class StaticPage
);
);
}
}
/**
* @return non-empty-string
*/
public
function
getOutputPathname
():
string
public
function
getOutputPathname
():
string
{
{
return
sprintf
(
return
sprintf
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment