Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added internet extension #27

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Container/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
65 changes: 65 additions & 0 deletions src/Extension/InternetExtension.php
Original file line number Diff line number Diff line change
@@ -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
}
65 changes: 65 additions & 0 deletions src/Implementation/Internet.php
Original file line number Diff line number Diff line change
@@ -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.
}
}