-
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #429 from hydephp/organize-and-restructure-code
Refactor HydeKernel code to organized single-used traits
- Loading branch information
Showing
4 changed files
with
146 additions
and
107 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php
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,71 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Foundation\Concerns; | ||
|
||
/** | ||
* @internal Single-use trait for the HydeKernel class. | ||
* | ||
* @see \Hyde\Framework\HydeKernel | ||
*/ | ||
trait ForwardsFilesystem | ||
{ | ||
public function path(string $path = ''): string | ||
{ | ||
return $this->filesystem->path($path); | ||
} | ||
|
||
public function vendorPath(string $path = ''): string | ||
{ | ||
return $this->filesystem->vendorPath($path); | ||
} | ||
|
||
public function copy(string $from, string $to): bool | ||
{ | ||
return $this->filesystem->copy($from, $to); | ||
} | ||
|
||
public function touch(string|array $path): bool | ||
{ | ||
return $this->filesystem->touch($path); | ||
} | ||
|
||
public function unlink(string|array $path): bool | ||
{ | ||
return $this->filesystem->unlink($path); | ||
} | ||
|
||
public function getModelSourcePath(string $model, string $path = ''): string | ||
{ | ||
return $this->filesystem->getModelSourcePath($model, $path); | ||
} | ||
|
||
public function getBladePagePath(string $path = ''): string | ||
{ | ||
return $this->filesystem->getBladePagePath($path); | ||
} | ||
|
||
public function getMarkdownPagePath(string $path = ''): string | ||
{ | ||
return $this->filesystem->getMarkdownPagePath($path); | ||
} | ||
|
||
public function getMarkdownPostPath(string $path = ''): string | ||
{ | ||
return $this->filesystem->getMarkdownPostPath($path); | ||
} | ||
|
||
public function getDocumentationPagePath(string $path = ''): string | ||
{ | ||
return $this->filesystem->getDocumentationPagePath($path); | ||
} | ||
|
||
public function getSiteOutputPath(string $path = ''): string | ||
{ | ||
return $this->filesystem->getSiteOutputPath($path); | ||
} | ||
|
||
public function pathToRelative(string $path): string | ||
{ | ||
return $this->filesystem->pathToRelative($path); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php
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,36 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Foundation\Concerns; | ||
|
||
/** | ||
* @internal Single-use trait for the HydeKernel class. | ||
* | ||
* @see \Hyde\Framework\HydeKernel | ||
*/ | ||
trait ForwardsHyperlinks | ||
{ | ||
public function formatHtmlPath(string $destination): string | ||
{ | ||
return $this->hyperlinks->formatHtmlPath($destination); | ||
} | ||
|
||
public function relativeLink(string $destination): string | ||
{ | ||
return $this->hyperlinks->relativeLink($destination); | ||
} | ||
|
||
public function image(string $name, bool $preferQualifiedUrl = false): string | ||
{ | ||
return $this->hyperlinks->image($name, $preferQualifiedUrl); | ||
} | ||
|
||
public function hasSiteUrl(): bool | ||
{ | ||
return $this->hyperlinks->hasSiteUrl(); | ||
} | ||
|
||
public function url(string $path = '', ?string $default = null): string | ||
{ | ||
return $this->hyperlinks->url($path, $default); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/framework/src/Foundation/Concerns/ImplementsStringHelpers.php
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,24 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Foundation\Concerns; | ||
|
||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @internal Single-use trait for the HydeKernel class. | ||
* | ||
* @see \Hyde\Framework\HydeKernel | ||
*/ | ||
trait ImplementsStringHelpers | ||
{ | ||
public function makeTitle(string $slug): string | ||
{ | ||
$alwaysLowercase = ['a', 'an', 'the', 'in', 'on', 'by', 'with', 'of', 'and', 'or', 'but']; | ||
|
||
return ucfirst(str_ireplace( | ||
$alwaysLowercase, | ||
$alwaysLowercase, | ||
Str::headline($slug) | ||
)); | ||
} | ||
} |
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