From ebc8ede81f9cb932c03a50529d96333cd8b5114a Mon Sep 17 00:00:00 2001 From: Pim Jansen <pjansen@senet.nl> Date: Wed, 18 Jan 2023 17:53:41 +0100 Subject: [PATCH] Added internet extension --- src/Container/ContainerBuilder.php | 2 + src/Extension/InternetExtension.php | 65 +++++++++++++++++++++++++++++ src/Implementation/Internet.php | 65 +++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 src/Extension/InternetExtension.php create mode 100644 src/Implementation/Internet.php diff --git a/src/Container/ContainerBuilder.php b/src/Container/ContainerBuilder.php index b48576f..195b502 100644 --- a/src/Container/ContainerBuilder.php +++ b/src/Container/ContainerBuilder.php @@ -5,6 +5,7 @@ namespace Faker\Core\Container; use Faker\Core\Extension\Extension; +use Faker\Core\Extension\InternetExtension; use Faker\Core\Extension\LanguageExtension; use Faker\Core\Extension\LoremExtension; use Faker\Core\Implementation; @@ -70,6 +71,7 @@ public static function defaultExtensions(): array ColorExtension::class => Implementation\Color::class, DateTimeExtension::class => Implementation\DateTime::class, FileExtension::class => Implementation\File::class, + InternetExtension::class => Implementation\Internet::class, LoremExtension::class => Implementation\Lorem::class, LanguageExtension::class => Implementation\Language::class, NumberExtension::class => Implementation\Number::class, diff --git a/src/Extension/InternetExtension.php b/src/Extension/InternetExtension.php new file mode 100644 index 0000000..8b058af --- /dev/null +++ b/src/Extension/InternetExtension.php @@ -0,0 +1,65 @@ +<?php + +namespace Faker\Core\Extension; + +/** + * @experimental This interface is experimental and does not fall under our BC promise + */ +interface InternetExtension extends Extension +{ + /** + * @example my-name@example.com + */ + public function email(): string; + + /** + * @example 'jdoe' + */ + public function username(): string; + + /** + * @example 'fY4èHdZv68' + */ + public function password(int $minLength = 6, int $maxLength = 20): string; + + /** + * @example 'tiramisu.com' + */ + public function domainName(): string; + + /** + * @example 'com' + */ + public function tld(): string; + + /** + * @example 'https://faker.example.com/' + */ + public function url(): string; + + /** + * @example 'aut-repellat-commodi-vel-itaque-nihil-id-saepe-nostrum' + */ + public function slug(int $wordCount = 6, bool $variableWordCount = true): string; + + /** + * @example '237.149.115.38' + */ + public function ipv4(): string; + + /** + * @example '35cd:186d:3e23:2986:ef9f:5b41:42a4:e6f1' + */ + public function ipv6(): string; + + /** + * @see https://tools.ietf.org/html/rfc1918#section-3 + * @example '10.1.1.17' + */ + public function localIpv4(): string; + + /** + * @example '32:F1:39:2F:D6:18' + */ + public static function macAddress(): string +} diff --git a/src/Implementation/Internet.php b/src/Implementation/Internet.php new file mode 100644 index 0000000..26e478f --- /dev/null +++ b/src/Implementation/Internet.php @@ -0,0 +1,65 @@ +<?php + +declare(strict_types=1); + +namespace Faker\Core\Implementation; + +use Faker\Core\Extension\InternetExtension; + +final class Internet implements InternetExtension +{ + public function email(): string + { + // TODO: Implement email() method. + } + + public function username(): string + { + // TODO: Implement username() method. + } + + public function password(int $minLength = 6, int $maxLength = 20): string + { + // TODO: Implement password() method. + } + + public function domainName(): string + { + // TODO: Implement domainName() method. + } + + public function tld(): string + { + // TODO: Implement tld() method. + } + + public function url(): string + { + // TODO: Implement url() method. + } + + public function slug(int $wordCount = 6, bool $variableWordCount = true): string + { + // TODO: Implement slug() method. + } + + public function ipv4(): string + { + // TODO: Implement ipv4() method. + } + + public function ipv6(): string + { + // TODO: Implement ipv6() method. + } + + public function localIpv4(): string + { + // TODO: Implement localIpv4() method. + } + + public static function macAddress(): string + { + // TODO: Implement macAddress() method. + } +}