-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
24 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,24 @@ | ||
<?php | ||
namespace Gt\Routing\LogicStream; | ||
|
||
class LogicStreamNamespace implements \Stringable { | ||
public function __construct( | ||
private string $path, | ||
private string $namespacePrefix = "" | ||
) { | ||
} | ||
|
||
public function __toString() { | ||
$namespace = $this->namespacePrefix; | ||
$pathParts = explode(DIRECTORY_SEPARATOR, $this->path); | ||
foreach($pathParts as $part) { | ||
$namespace .= "\\$part"; | ||
} | ||
|
||
return str_replace( | ||
["@", "-", "+", "~", "%", "."], | ||
"_", | ||
$namespace | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,7 @@ | |
namespace Gt\Routing\Path; | ||
|
||
class DynamicPath { | ||
|
||
public function get(string $key):string { | ||
return "TODO"; | ||
} | ||
} |
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
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
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,47 @@ | ||
<?php | ||
namespace Gt\Routing\Test\Path\FileMatch; | ||
|
||
use Gt\Routing\Path\FileMatch\MagicFileMatch; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MagicFileMatchTest extends TestCase { | ||
public function testMatches_none():void { | ||
$sut = new MagicFileMatch( | ||
"basedir/something/nested.txt", | ||
"basedir" | ||
); | ||
self::assertFalse($sut->matches("/")); | ||
} | ||
|
||
public function testMatches_noDirectMatch():void { | ||
$sut = new MagicFileMatch( | ||
"basedir/something/nested.txt", | ||
"basedir" | ||
); | ||
self::assertFalse($sut->matches("/something/nested")); | ||
} | ||
|
||
public function testMatches_sameDir():void { | ||
$sut = new MagicFileMatch( | ||
"basedir/something/_common.php", | ||
"basedir" | ||
); | ||
self::assertTrue($sut->matches("/something/nested")); | ||
} | ||
|
||
public function testMatches_parentDir():void { | ||
$sut = new MagicFileMatch( | ||
"basedir/_common.php", | ||
"basedir" | ||
); | ||
self::assertTrue($sut->matches("/something/nested")); | ||
} | ||
|
||
public function testMatches_ancestorDir():void { | ||
$sut = new MagicFileMatch( | ||
"basedir/something/_common.php", | ||
"basedir" | ||
); | ||
self::assertTrue($sut->matches("/something/very/deeply/nested")); | ||
} | ||
} |