-
-
Notifications
You must be signed in to change notification settings - Fork 68
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 #181 from thephpleague/feature/adding-psr7-uri-fac…
…tory Adding HttpFactory class
- Loading branch information
Showing
4 changed files
with
62 additions
and
5 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
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,25 @@ | ||
<?php | ||
|
||
/** | ||
* League.Uri (https://uri.thephpleague.com) | ||
* | ||
* (c) Ignace Nyamagana Butera <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\Uri; | ||
|
||
use Psr\Http\Message\UriFactoryInterface; | ||
use Psr\Http\Message\UriInterface; | ||
|
||
final class HttpFactory implements UriFactoryInterface | ||
{ | ||
public function createUri(string $uri = ''): UriInterface | ||
{ | ||
return Http::createFromString($uri); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
/** | ||
* League.Uri (https://uri.thephpleague.com) | ||
* | ||
* (c) Ignace Nyamagana Butera <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LeagueTest\Uri; | ||
|
||
use League\Uri\Http; | ||
use League\Uri\HttpFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class HttpFactoryTest extends TestCase | ||
{ | ||
public function testCreateUri(): void | ||
{ | ||
$factory = new HttpFactory(); | ||
$uri = $factory->createUri('https://nyholm.tech/foo'); | ||
|
||
self::assertInstanceOf(Http::class, $uri); | ||
self::assertEquals('https://nyholm.tech/foo', $uri->__toString()); | ||
} | ||
} |