repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/tests/App/Modules/Routes/Extractors/Stubs/FormRequestStub.php
tests/App/Modules/Routes/Extractors/Stubs/FormRequestStub.php
<?php namespace Sunchayn\Nimbus\Tests\App\Modules\Routes\Extractors\Stubs; use Illuminate\Http\Request; class FormRequestStub extends Request { public function rules(): array { return [ 'name' => 'required|string', 'email' => 'required|email', ]; } }
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/tests/App/Modules/Routes/Extractors/Stubs/FormRequestWithExceptionStub.php
tests/App/Modules/Routes/Extractors/Stubs/FormRequestWithExceptionStub.php
<?php namespace Sunchayn\Nimbus\Tests\App\Modules\Routes\Extractors\Stubs; use Illuminate\Http\Request; class FormRequestWithExceptionStub extends Request { public function rules(): array { throw new \RuntimeException('Cannot access request context'); } }
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/tests/App/Commands/Intellisense/GenerateIntellisenseCommandFunctionalTest.php
tests/App/Commands/Intellisense/GenerateIntellisenseCommandFunctionalTest.php
<?php namespace Sunchayn\Nimbus\Tests\App\Commands\Intellisense; use Carbon\CarbonImmutable; use Mockery; use PHPUnit\Framework\Attributes\CoversClass; use RuntimeException; use Sunchayn\Nimbus\Commands\Intellisense\GenerateIntellisenseCommand; use Sunchayn\Nimbus\IntellisenseProviders\Contracts\IntellisenseContract; use Sunchayn\Nimbus\Tests\App\Commands\Intellisense\Stubs\Providers\FakeProviderOne; use Sunchayn\Nimbus\Tests\App\Commands\Intellisense\Stubs\Providers\FakeProviderTwo; use Sunchayn\Nimbus\Tests\TestCase; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\OutputInterface; #[CoversClass(GenerateIntellisenseCommand::class)] class GenerateIntellisenseCommandFunctionalTest extends TestCase { private const GENERATED_BASE_PATH = __DIR__.'/../../../../resources/js/interfaces/generated'; protected function setUp(): void { parent::setUp(); CarbonImmutable::setTestNow(CarbonImmutable::now()); } protected function tearDown(): void { @unlink(self::GENERATED_BASE_PATH.'/fake-provider-one.ts'); @unlink(self::GENERATED_BASE_PATH.'/fake-provider-two.ts'); parent::tearDown(); } public function test_it_generates_intellisense_properly(): void { // Arrange $command = resolve(GenerateIntellisenseCommand::class); invade($command)->intellisenseProviders = [ FakeProviderOne::class, FakeProviderTwo::class, ]; $input = Mockery::mock(StringInput::class)->makePartial(); $output = Mockery::mock(OutputInterface::class); // <helper> Uncomment for debug // $output->shouldReceive('writeln')->withAnyArgs()->andReturnUsing(fn ($values) => dump($values)); // Anticipate $output->shouldReceive('write')->once(); $output->shouldReceive('writeln')->with("\n")->once(); $output->shouldReceive('writeln')->with(' >> <info>Generating TypeScript Intellisense...</info>')->once(); $output->shouldReceive('writeln')->with("\n> Generating fake-provider-one.ts")->once(); $output->shouldReceive('writeln')->with('<info>✓ Generated.</info>')->once(); $output->shouldReceive('writeln')->with("\n> Generating fake-provider-two.ts")->once(); $output->shouldReceive('writeln')->with('<info>✓ Generated.</info>')->once(); $output->shouldReceive('writeln')->with("\n<info>✓ All Intellisense generated successfully!</info>")->once(); // Act $result = $command->run($input, $output); // Assert $this->assertEquals(Command::SUCCESS, $result); $this->assertEquals( $this->getExpectedContentForProviderOne(), file_get_contents(self::GENERATED_BASE_PATH.'/fake-provider-one.ts'), ); $this->assertEquals( $this->getExpectedContentForProviderTwo(), file_get_contents(self::GENERATED_BASE_PATH.'/fake-provider-two.ts'), ); } public function test_it_handles_intellisense_generation_failure(): void { // Arrange $command = resolve(GenerateIntellisenseCommand::class); $input = Mockery::mock(StringInput::class)->makePartial(); $output = Mockery::mock(OutputInterface::class); $failingIntellisenseDummy = new class implements IntellisenseContract { public function getTargetFileName(): string { return 'test.ts'; } public function generate(): string { throw new RuntimeException('Generation failed'); } }; invade($command)->intellisenseProviders = [ $failingIntellisenseDummy::class, ]; // Anticipate $output->shouldReceive('write')->once(); $output->shouldReceive('writeln')->with("\n")->once(); $output->shouldReceive('writeln')->with(' >> <info>Generating TypeScript Intellisense...</info>')->once(); $output->shouldReceive('writeln')->with("\n> Generating test.ts")->once(); $output->shouldReceive('writeln')->with('')->once(); $output->shouldReceive('writeln')->with('<error>Failed to generate:</error>.')->once(); $output->shouldReceive('writeln')->with('Generation failed')->once(); $output->shouldReceive('writeln')->with('')->once(); // Act $result = $command->run($input, $output); // Assert $this->assertEquals(Command::FAILURE, $result); } /* * Helpers. */ private function getExpectedContentForProviderOne(): string { $datetime = CarbonImmutable::now()->toIso8601String(); return <<<EXPECTED /* * This file is auto-generated. * Don't update it manually, otherwise, your changes will be lost. * To update the file run `php bin/intellisense`. * * Generated at: $datetime. */ type FakeProviderOne = string; enum FakeOneValues { foo = 'bar', bar = 'baz', } EXPECTED; } private function getExpectedContentForProviderTwo(): string { $datetime = CarbonImmutable::now()->toIso8601String(); return <<<EXPECTED /* * This file is auto-generated. * Don't update it manually, otherwise, your changes will be lost. * To update the file run `php bin/intellisense`. * * Generated at: $datetime. */ enum FakeTwoValues { foo = 'bar', bar = 'baz', } type FakeProviderTwo = number; EXPECTED; } }
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/tests/App/Commands/Intellisense/Stubs/Providers/FakeProviderTwo.php
tests/App/Commands/Intellisense/Stubs/Providers/FakeProviderTwo.php
<?php namespace Sunchayn\Nimbus\Tests\App\Commands\Intellisense\Stubs\Providers; class FakeProviderTwo extends FakeProviderOne { public function getStub(): string { return 'fake-provider-two.ts.stub'; } }
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/tests/App/Commands/Intellisense/Stubs/Providers/FakeProviderOne.php
tests/App/Commands/Intellisense/Stubs/Providers/FakeProviderOne.php
<?php namespace Sunchayn\Nimbus\Tests\App\Commands\Intellisense\Stubs\Providers; use Illuminate\Support\Str; use RuntimeException; use Sunchayn\Nimbus\IntellisenseProviders\Contracts\IntellisenseContract; class FakeProviderOne implements IntellisenseContract { public function getStub(): string { return 'fake-provider-one.ts.stub'; } public function getTargetFileName(): string { /** @phpstan-return non-empty-string */ return Str::remove('.stub', $this->getStub()); } public function generate(): string { $enumCases = []; foreach (['foo' => 'bar', 'bar' => 'baz'] as $key => $value) { $enumCases[] = " {$key} = '{$value}',"; } $enumContent = implode("\n", $enumCases); return $this->replaceStubContent($enumContent); } private function replaceStubContent(string $enumList): string { $stubFile = file_get_contents(__DIR__.'/../'.$this->getStub()) ?: throw new RuntimeException('Cannot read stub file.'); return str_replace('{{ content }}', rtrim($enumList), $stubFile); } }
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/routes/web.php
routes/web.php
<?php use Illuminate\Support\Facades\Route; use Sunchayn\Nimbus\Http\Web\Controllers\NimbusIndexController; Route::group( [ 'domain' => config('nimbus.domain'), 'prefix' => config('nimbus.prefix'), 'middleware' => 'web', ], function () { Route::get('/{view?}', NimbusIndexController::class) ->where('view', '(.*)') ->name('nimbus.index'); }, );
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/routes/api.php
routes/api.php
<?php use Illuminate\Support\Facades\Route; use Sunchayn\Nimbus\Http\Api\Relay\NimbusRelayController; Route::group( [ 'domain' => config('nimbus.domain'), 'prefix' => config('nimbus.prefix').'/api', ], function () { Route::post('/relay', NimbusRelayController::class) ->name('nimbus.api.relay'); }, );
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/config/nimbus.php
config/nimbus.php
<?php return [ /* |-------------------------------------------------------------------------- | Nimbus UI Prefix |-------------------------------------------------------------------------- | | This value defines the URI prefix for the Nimbus UI. The interface will | be accessible at {your-domain}/{prefix}. You may change this to integrate | Nimbus into a specific route namespace within your application. | */ 'prefix' => 'nimbus', /* |-------------------------------------------------------------------------- | Allowed Environments |-------------------------------------------------------------------------- | | Specifies in which environments Nimbus is enabled. It is recommended | to exclude Nimbus from production as some features, such as user | impersonation, pose security risks. Use caution when enabling in | sensitive environments. | */ 'allowed_envs' => ['local', 'staging'], /* |-------------------------------------------------------------------------- | Route Configuration |-------------------------------------------------------------------------- | | These options control how Nimbus identifies and registers application | routes. The route configuration determines which endpoints will be | analyzed, displayed, or interacted with by Nimbus. */ 'routes' => [ /* |-------------------------------------------------------------------------- | Route Prefix |-------------------------------------------------------------------------- | | The prefix used to discover and filter the routes for inclusion in Nimbus. | Only routes whose URIs begin with this prefix will be loaded in the UI. | Adjust this value if your API endpoints use a different root segment. | */ 'prefix' => 'api', /* |-------------------------------------------------------------------------- | Versioned Routes |-------------------------------------------------------------------------- | | Determines whether the routes identified by the prefix should be | treated as versioned (for example: /api/v1/users). If enabled, Nimbus | automatically detects version segments and handles them separately | in the schema representation. Disable this if your routes are flat | or non-versioned. | */ 'versioned' => false, /* |-------------------------------------------------------------------------- | API Base URL |-------------------------------------------------------------------------- | | This value defines the base URL that Nimbus will use when relaying | API requests from the UI. It is useful in cases where your API is | hosted on a different domain, port, or subpath than the UI itself. | | If left null, Nimbus will automatically use the same host and scheme | as the incoming request that triggered the relay. This is the | recommended default for most deployments where the API and UI share | the same origin. | */ 'api_base_url' => null, ], /* |-------------------------------------------------------------------------- | Authentication Configuration |-------------------------------------------------------------------------- | | Defines how Nimbus authenticates API requests when interacting with your | application routes. The authentication configuration determines which | Laravel guard is used and how special authentication modes—such as | “login as current user” or “impersonate user” are handled. | */ 'auth' => [ /* |-------------------------------------------------------------------------- | Authentication Guard |-------------------------------------------------------------------------- | | The name of the Laravel authentication guard used for the api endpoints. | This guard must be the guard used to authenticate the requests to | the API endpoints from the prefix above (nimbus.routes.prefix). */ 'guard' => 'web', /* |-------------------------------------------------------------------------- | Special Authentication |-------------------------------------------------------------------------- | | These settings control Nimbus's advanced authentication modes, | such as impersonation or logging in as the current user. Each mode | modifies outgoing HTTP requests by injecting appropriate credentials | or tokens before they are sent. | */ 'special' => [ /* |-------------------------------------------------------------------------- | Authentication Injector |-------------------------------------------------------------------------- | | Defines the injector class used to modify outgoing requests with | authentication credentials. The class must implement the | `SpecialAuthenticationInjectorContract` interface. | | Included implementations: | - RememberMeCookieInjector::class: | Forwards or generates a Laravel "remember me" cookie. | - TymonJwtTokenInjector::class: | Injects a Bearer token using the `tymon/jwt-aut` package. | | P.S. You may provide a custom implementation to support alternative authentication mechanisms. */ 'injector' => \Sunchayn\Nimbus\Modules\Relay\Authorization\Injectors\RememberMeCookieInjector::class, ], ], /* |-------------------------------------------------------------------------- | Global Headers |-------------------------------------------------------------------------- | | Define any global headers that should be applied to every Nimbus request. | Each header may be defined as either: | - A value from GlobalHeaderGeneratorTypeEnum::class, or | - A raw primitive value (string, integer, or boolean). | | Example: | 'headers' => [ | 'X-Request-ID' => GlobalHeaderGeneratorTypeEnum::UUID, | 'X-App-Version' => '1.0.0', | ], | */ 'headers' => [ /** @see \Sunchayn\Nimbus\Modules\Config\GlobalHeaderGeneratorTypeEnum */ ], ];
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
sunchayn/nimbus
https://github.com/sunchayn/nimbus/blob/8bdd510f179b0c86175557d41fbda2797a41a507/resources/views/app.blade.php
resources/views/app.blade.php
<!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/png" href="{{ asset('/vendor/nimbus/favicon/favicon-96x96.png') }}" sizes="96x96" /> <link rel="icon" type="image/svg+xml" href="{{ asset('/vendor/nimbus/favicon/favicon.svg') }}" /> <link rel="shortcut icon" href="{{ asset('/vendor/nimbus/favicon/favicon.ico') }}" /> <link rel="apple-touch-icon" sizes="180x180" href="{{ asset('/vendor/nimbus/favicon/apple-touch-icon.png') }}" /> <meta name="apple-mobile-web-app-title" content="Nimbus" /> <title>{{ config('app.name', 'Laravel') }} - Nimbus</title> <!-- Fonts --> <link rel="preconnect" href="https://fonts.bunny.net"> <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" /> <script> (function() { const appearance = '{{ $appearance ?? "system" }}'; if (appearance === 'system') { const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; if (prefersDark) { document.documentElement.classList.add('dark'); } } })(); </script> @php $config = \Illuminate\Support\Js::from([ 'basePath' => rtrim(\Illuminate\Support\Str::start(config('nimbus.prefix'), '/'), '/'), 'routes' => isset($routes) ? json_encode($routes) : null, 'headers' => isset($headers) ? json_encode($headers) : null, 'routeExtractorException' => isset($routeExtractorException) ? json_encode($routeExtractorException) : null, 'isVersioned' => config('nimbus.routes.versioned'), 'apiBaseUrl' => config('nimbus.routes.api_base_url', request()->getSchemeAndHttpHost()), 'currentUser' => isset($currentUser) ? json_encode($currentUser) : null, ]); $configTag = new \Illuminate\Support\HtmlString(<<<HTML <script type="module"> window.Nimbus = {$config}; </script> HTML); @endphp {{ $configTag }} @vite(['resources/css/app.css', 'resources/js/app/app.ts']) </head> <body class="font-sans antialiased"> <div id="app"></div> </body> </html>
php
MIT
8bdd510f179b0c86175557d41fbda2797a41a507
2026-01-05T05:17:17.516160Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/LanguageInterface.php
src/LanguageInterface.php
<?php namespace TheIconic\NameParser; interface LanguageInterface { public function getSuffixes(): array; public function getLastnamePrefixes(): array; public function getSalutations(): array; }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Name.php
src/Name.php
<?php namespace TheIconic\NameParser; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\GivenNamePart; class Name { private const PARTS_NAMESPACE = 'TheIconic\NameParser\Part'; /** * @var array the parts that make up this name */ protected $parts = []; /** * constructor takes the array of parts this name consists of * * @param array|null $parts */ public function __construct(array $parts = null) { if (null !== $parts) { $this->setParts($parts); } } /** * @return string */ public function __toString(): string { return implode(' ', $this->getAll(true)); } /** * set the parts this name consists of * * @param array $parts * @return $this */ public function setParts(array $parts): Name { $this->parts = $parts; return $this; } /** * get the parts this name consists of * * @return array */ public function getParts(): array { return $this->parts; } /** * @param bool $format * @return array */ public function getAll(bool $format = false): array { $results = []; $keys = [ 'salutation' => [], 'firstname' => [], 'nickname' => [$format], 'middlename' => [], 'initials' => [], 'lastname' => [], 'suffix' => [], ]; foreach ($keys as $key => $args) { $method = sprintf('get%s', ucfirst($key)); if ($value = call_user_func_array(array($this, $method), $args)) { $results[$key] = $value; }; } return $results; } /** * get the given name (first name, middle names and initials) * in the order they were entered while still applying normalisation * * @return string */ public function getGivenName(): string { return $this->export('GivenNamePart'); } /** * get the given name followed by the last name (including any prefixes) * * @return string */ public function getFullName(): string { return sprintf('%s %s', $this->getGivenName(), $this->getLastname()); } /** * get the first name * * @return string */ public function getFirstname(): string { return $this->export('Firstname'); } /** * get the last name * * @param bool $pure * @return string */ public function getLastname(bool $pure = false): string { return $this->export('Lastname', $pure); } /** * get the last name prefix * * @return string */ public function getLastnamePrefix(): string { return $this->export('LastnamePrefix'); } /** * get the initials * * @return string */ public function getInitials(): string { return $this->export('Initial'); } /** * get the suffix(es) * * @return string */ public function getSuffix(): string { return $this->export('Suffix'); } /** * get the salutation(s) * * @return string */ public function getSalutation(): string { return $this->export('Salutation'); } /** * get the nick name(s) * * @param bool $wrap * @return string */ public function getNickname(bool $wrap = false): string { if ($wrap) { return sprintf('(%s)', $this->export('Nickname')); } return $this->export('Nickname'); } /** * get the middle name(s) * * @return string */ public function getMiddlename(): string { return $this->export('Middlename'); } /** * helper method used by getters to extract and format relevant name parts * * @param string $type * @param bool $strict * @return string */ protected function export(string $type, bool $strict = false): string { $matched = []; foreach ($this->parts as $part) { if ($part instanceof AbstractPart && $this->isType($part, $type, $strict)) { $matched[] = $part->normalize(); } } return implode(' ', $matched); } /** * helper method to check if a part is of the given type * * @param AbstractPart $part * @param string $type * @param bool $strict * @return bool */ protected function isType(AbstractPart $part, string $type, bool $strict = false): bool { $className = sprintf('%s\\%s', self::PARTS_NAMESPACE, $type); if ($strict) { return get_class($part) === $className; } return is_a($part, $className); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Parser.php
src/Parser.php
<?php namespace TheIconic\NameParser; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Mapper\NicknameMapper; use TheIconic\NameParser\Mapper\SalutationMapper; use TheIconic\NameParser\Mapper\SuffixMapper; use TheIconic\NameParser\Mapper\InitialMapper; use TheIconic\NameParser\Mapper\LastnameMapper; use TheIconic\NameParser\Mapper\FirstnameMapper; use TheIconic\NameParser\Mapper\MiddlenameMapper; class Parser { /** * @var string */ protected $whitespace = " \r\n\t"; /** * @var array */ protected $mappers = []; /** * @var array */ protected $languages = []; /** * @var array */ protected $nicknameDelimiters = []; /** * @var int */ protected $maxSalutationIndex = 0; /** * @var int */ protected $maxCombinedInitials = 2; public function __construct(array $languages = []) { if (empty($languages)) { $languages = [new English()]; } $this->languages = $languages; } /** * split full names into the following parts: * - prefix / salutation (Mr., Mrs., etc) * - given name / first name * - middle initials * - surname / last name * - suffix (II, Phd, Jr, etc) * * @param string $name * @return Name */ public function parse($name): Name { $name = $this->normalize($name); $segments = explode(',', $name); if (1 < count($segments)) { return $this->parseSplitName($segments[0], $segments[1], $segments[2] ?? ''); } $parts = explode(' ', $name); foreach ($this->getMappers() as $mapper) { $parts = $mapper->map($parts); } return new Name($parts); } /** * handles split-parsing of comma-separated name parts * * @param $left - the name part left of the comma * @param $right - the name part right of the comma * * @return Name */ protected function parseSplitName($first, $second, $third): Name { $parts = array_merge( $this->getFirstSegmentParser()->parse($first)->getParts(), $this->getSecondSegmentParser()->parse($second)->getParts(), $this->getThirdSegmentParser()->parse($third)->getParts() ); return new Name($parts); } /** * @return Parser */ protected function getFirstSegmentParser(): Parser { $parser = new Parser(); $parser->setMappers([ new SalutationMapper($this->getSalutations(), $this->getMaxSalutationIndex()), new SuffixMapper($this->getSuffixes(), false, 2), new LastnameMapper($this->getPrefixes(), true), new FirstnameMapper(), new MiddlenameMapper(), ]); return $parser; } /** * @return Parser */ protected function getSecondSegmentParser(): Parser { $parser = new Parser(); $parser->setMappers([ new SalutationMapper($this->getSalutations(), $this->getMaxSalutationIndex()), new SuffixMapper($this->getSuffixes(), true, 1), new NicknameMapper($this->getNicknameDelimiters()), new InitialMapper($this->getMaxCombinedInitials(), true), new FirstnameMapper(), new MiddlenameMapper(true), ]); return $parser; } protected function getThirdSegmentParser(): Parser { $parser = new Parser(); $parser->setMappers([ new SuffixMapper($this->getSuffixes(), true, 0), ]); return $parser; } /** * get the mappers for this parser * * @return array */ public function getMappers(): array { if (empty($this->mappers)) { $this->setMappers([ new NicknameMapper($this->getNicknameDelimiters()), new SalutationMapper($this->getSalutations(), $this->getMaxSalutationIndex()), new SuffixMapper($this->getSuffixes()), new InitialMapper($this->getMaxCombinedInitials()), new LastnameMapper($this->getPrefixes()), new FirstnameMapper(), new MiddlenameMapper(), ]); } return $this->mappers; } /** * set the mappers for this parser * * @param array $mappers * @return Parser */ public function setMappers(array $mappers): Parser { $this->mappers = $mappers; return $this; } /** * normalize the name * * @param string $name * @return string */ protected function normalize(string $name): string { $whitespace = $this->getWhitespace(); $name = trim($name); return preg_replace('/[' . preg_quote($whitespace) . ']+/', ' ', $name); } /** * get a string of characters that are supposed to be treated as whitespace * * @return string */ public function getWhitespace(): string { return $this->whitespace; } /** * set the string of characters that are supposed to be treated as whitespace * * @param $whitespace * @return Parser */ public function setWhitespace($whitespace): Parser { $this->whitespace = $whitespace; return $this; } /** * @return array */ protected function getPrefixes() { $prefixes = []; /** @var LanguageInterface $language */ foreach ($this->languages as $language) { $prefixes += $language->getLastnamePrefixes(); } return $prefixes; } /** * @return array */ protected function getSuffixes() { $suffixes = []; /** @var LanguageInterface $language */ foreach ($this->languages as $language) { $suffixes += $language->getSuffixes(); } return $suffixes; } /** * @return array */ protected function getSalutations() { $salutations = []; /** @var LanguageInterface $language */ foreach ($this->languages as $language) { $salutations += $language->getSalutations(); } return $salutations; } /** * @return array */ public function getNicknameDelimiters(): array { return $this->nicknameDelimiters; } /** * @param array $nicknameDelimiters * @return Parser */ public function setNicknameDelimiters(array $nicknameDelimiters): Parser { $this->nicknameDelimiters = $nicknameDelimiters; return $this; } /** * @return int */ public function getMaxSalutationIndex(): int { return $this->maxSalutationIndex; } /** * @param int $maxSalutationIndex * @return Parser */ public function setMaxSalutationIndex(int $maxSalutationIndex): Parser { $this->maxSalutationIndex = $maxSalutationIndex; return $this; } /** * @return int */ public function getMaxCombinedInitials(): int { return $this->maxCombinedInitials; } /** * @param int $maxCombinedInitials * @return Parser */ public function setMaxCombinedInitials(int $maxCombinedInitials): Parser { $this->maxCombinedInitials = $maxCombinedInitials; return $this; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Firstname.php
src/Part/Firstname.php
<?php namespace TheIconic\NameParser\Part; class Firstname extends GivenNamePart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Lastname.php
src/Part/Lastname.php
<?php namespace TheIconic\NameParser\Part; class Lastname extends NamePart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/NamePart.php
src/Part/NamePart.php
<?php namespace TheIconic\NameParser\Part; abstract class NamePart extends AbstractPart { /** * camelcase the lastname * * @return string */ public function normalize(): string { return $this->camelcase($this->getValue()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Middlename.php
src/Part/Middlename.php
<?php namespace TheIconic\NameParser\Part; class Middlename extends GivenNamePart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/PreNormalizedPart.php
src/Part/PreNormalizedPart.php
<?php namespace TheIconic\NameParser\Part; abstract class PreNormalizedPart extends AbstractPart { protected $normalized = ''; public function __construct(string $value, string $normalized = null) { $this->normalized = $normalized ?? $value; parent::__construct($value); } /** * if this is a lastname prefix, look up normalized version from registry * otherwise camelcase the lastname * * @return string */ public function normalize(): string { return $this->normalized; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Salutation.php
src/Part/Salutation.php
<?php namespace TheIconic\NameParser\Part; class Salutation extends PreNormalizedPart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/GivenNamePart.php
src/Part/GivenNamePart.php
<?php namespace TheIconic\NameParser\Part; abstract class GivenNamePart extends NamePart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Nickname.php
src/Part/Nickname.php
<?php namespace TheIconic\NameParser\Part; class Nickname extends AbstractPart { /** * camelcase the nickname for normalization * * @return string */ public function normalize(): string { return $this->camelcase($this->getValue()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/AbstractPart.php
src/Part/AbstractPart.php
<?php namespace TheIconic\NameParser\Part; abstract class AbstractPart { /** * @var string the wrapped value */ protected $value; /** * constructor allows passing the value to wrap * * @param $value */ public function __construct($value) { $this->setValue($value); } /** * set the value to wrap * (can take string or part instance) * * @param string|AbstractPart $value * @return $this */ public function setValue($value): AbstractPart { if ($value instanceof AbstractPart) { $value = $value->getValue(); } $this->value = $value; return $this; } /** * get the wrapped value * * @return string */ public function getValue(): string { return $this->value; } /** * get the normalized value * * @return string */ public function normalize(): string { return $this->getValue(); } /** * helper for camelization of values * to be used during normalize * * @param $word * @return mixed */ protected function camelcase($word): string { if (preg_match('/\p{L}(\p{Lu}*\p{Ll}\p{Ll}*\p{Lu}|\p{Ll}*\p{Lu}\p{Lu}*\p{Ll})\p{L}*/u', $word)) { return $word; } return preg_replace_callback('/[\p{L}0-9]+/ui', [$this, 'camelcaseReplace'], $word); } /** * camelcasing callback * * @param $matches * @return string */ protected function camelcaseReplace($matches): string { if (function_exists('mb_convert_case')) { return mb_convert_case($matches[0], MB_CASE_TITLE, 'UTF-8'); } return ucfirst(strtolower($matches[0])); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/LastnamePrefix.php
src/Part/LastnamePrefix.php
<?php namespace TheIconic\NameParser\Part; class LastnamePrefix extends Lastname { protected $normalized = ''; public function __construct(string $value, string $normalized = null) { $this->normalized = $normalized ?? $value; parent::__construct($value); } /** * if this is a lastname prefix, look up normalized version from registry * otherwise camelcase the lastname * * @return string */ public function normalize(): string { return $this->normalized; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Initial.php
src/Part/Initial.php
<?php namespace TheIconic\NameParser\Part; class Initial extends GivenNamePart { /** * uppercase the initial * * @return string */ public function normalize(): string { return strtoupper($this->getValue()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Part/Suffix.php
src/Part/Suffix.php
<?php namespace TheIconic\NameParser\Part; class Suffix extends PreNormalizedPart { }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Language/German.php
src/Language/German.php
<?php namespace TheIconic\NameParser\Language; use TheIconic\NameParser\LanguageInterface; class German implements LanguageInterface { const SUFFIXES = [ '1.' => '1.', '2.' => '2.', '3.' => '3.', '4.' => '4.', '5.' => '5.', 'i' => 'I', 'ii' => 'II', 'iii' => 'III', 'iv' => 'IV', 'v' => 'V', ]; const SALUTATIONS = [ 'herr' => 'Herr', 'hr' => 'Herr', 'frau' => 'Frau', 'fr' => 'Frau' ]; const LASTNAME_PREFIXES = [ 'der' => 'der', 'von' => 'von', ]; public function getSuffixes(): array { return self::SUFFIXES; } public function getSalutations(): array { return self::SALUTATIONS; } public function getLastnamePrefixes(): array { return self::LASTNAME_PREFIXES; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Language/English.php
src/Language/English.php
<?php namespace TheIconic\NameParser\Language; use TheIconic\NameParser\LanguageInterface; class English implements LanguageInterface { const SUFFIXES = [ '1st' => '1st', '2nd' => '2nd', '3rd' => '3rd', '4th' => '4th', '5th' => '5th', 'i' => 'I', 'ii' => 'II', 'iii' => 'III', 'iv' => 'IV', 'v' => 'V', 'apr' => 'APR', 'cme' => 'CME', 'dds' => 'DDS', 'dmd' => 'DMD', 'dvm' => 'DVM', 'esq' => 'Esq', 'jr' => 'Jr', 'junior' => 'Junior', 'ma' => 'MA', 'md' => 'MD', 'pe' => 'PE', 'phd' => 'PhD', 'rph' => 'RPh', 'senior' => 'Senior', 'sr' => 'Sr', ]; const SALUTATIONS = [ 'dr' => 'Dr.', 'fr' => 'Fr.', 'madam' => 'Madam', 'master' => 'Mr.', 'miss' => 'Miss', 'mister' => 'Mr.', 'mr' => 'Mr.', 'mrs' => 'Mrs.', 'ms' => 'Ms.', 'mx' => 'Mx.', 'rev' => 'Rev.', 'sir' => 'Sir', 'prof' => 'Prof.', 'his honour' => 'His Honour', 'her honour' => 'Her Honour' ]; const LASTNAME_PREFIXES = [ 'da' => 'da', 'de' => 'de', 'del' => 'del', 'della' => 'della', 'der' => 'der', 'di' => 'di', 'du' => 'du', 'la' => 'la', 'pietro' => 'pietro', 'st' => 'st.', 'ter' => 'ter', 'van' => 'van', 'vanden' => 'vanden', 'vere' => 'vere', 'von' => 'von', ]; public function getSuffixes(): array { return self::SUFFIXES; } public function getSalutations(): array { return self::SALUTATIONS; } public function getLastnamePrefixes(): array { return self::LASTNAME_PREFIXES; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/SalutationMapper.php
src/Mapper/SalutationMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Salutation; class SalutationMapper extends AbstractMapper { protected $salutations = []; protected $maxIndex = 0; public function __construct(array $salutations, $maxIndex = 0) { $this->salutations = $salutations; $this->maxIndex = $maxIndex; } /** * map salutations in the parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { $max = ($this->maxIndex > 0) ? $this->maxIndex : floor(count($parts) / 2); for ($k = 0; $k < $max; $k++) { if ($parts[$k] instanceof AbstractPart) { break; } $parts = $this->substituteWithSalutation($parts, $k); } return $parts; } /** * We pass the full parts array and the current position to allow * not only single-word matches but also combined matches with * subsequent words (parts). * * @param array $parts * @param int $start * @return array */ protected function substituteWithSalutation(array $parts, int $start): array { if ($this->isSalutation($parts[$start])) { $parts[$start] = new Salutation($parts[$start], $this->salutations[$this->getKey($parts[$start])]); return $parts; } foreach ($this->salutations as $key => $salutation) { $keys = explode(' ', $key); $length = count($keys); $subset = array_slice($parts, $start, $length); if ($this->isMatchingSubset($keys, $subset)) { array_splice($parts, $start, $length, [new Salutation(implode(' ', $subset), $salutation)]); return $parts; } } return $parts; } /** * check if the given subset matches the given keys entry by entry, * which means word by word, except that we first need to key-ify * the subset words * * @param array $keys * @param array $subset * @return bool */ private function isMatchingSubset(array $keys, array $subset): bool { for ($i = 0; $i < count($subset); $i++) { if ($this->getKey($subset[$i]) !== $keys[$i]) { return false; } } return true; } /** * check if the given word is a viable salutation * * @param string $word the word to check * @return bool */ protected function isSalutation($word): bool { return (array_key_exists($this->getKey($word), $this->salutations)); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/SuffixMapper.php
src/Mapper/SuffixMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Suffix; class SuffixMapper extends AbstractMapper { protected $suffixes = []; protected $matchSinglePart = false; protected $reservedParts = 2; public function __construct(array $suffixes, bool $matchSinglePart = false, int $reservedParts = 2) { $this->suffixes = $suffixes; $this->matchSinglePart = $matchSinglePart; $this->reservedParts = $reservedParts; } /** * map suffixes in the parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { if ($this->isMatchingSinglePart($parts)) { $parts[0] = new Suffix($parts[0], $this->suffixes[$this->getKey($parts[0])]); return $parts; } $start = count($parts) - 1; for ($k = $start; $k > $this->reservedParts - 1; $k--) { $part = $parts[$k]; if (!$this->isSuffix($part)) { break; } $parts[$k] = new Suffix($part, $this->suffixes[$this->getKey($part)]); } return $parts; } /** * @param $parts * @return bool */ protected function isMatchingSinglePart($parts): bool { if (!$this->matchSinglePart) { return false; } if (1 !== count($parts)) { return false; } return $this->isSuffix($parts[0]); } /** * @param $part * @return bool */ protected function isSuffix($part): bool { if ($part instanceof AbstractPart) { return false; } return (array_key_exists($this->getKey($part), $this->suffixes)); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/LastnameMapper.php
src/Mapper/LastnameMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\LanguageInterface; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\LastnamePrefix; use TheIconic\NameParser\Part\Nickname; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Suffix; class LastnameMapper extends AbstractMapper { protected $prefixes = []; protected $matchSinglePart = false; public function __construct(array $prefixes, bool $matchSinglePart = false) { $this->prefixes = $prefixes; $this->matchSinglePart = $matchSinglePart; } /** * map lastnames in the parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { if (!$this->matchSinglePart && count($parts) < 2) { return $parts; } return $this->mapParts($parts); } /** * we map the parts in reverse order because it makes more * sense to parse for the lastname starting from the end * * @param array $parts * @return array */ protected function mapParts(array $parts): array { $k = $this->skipIgnoredParts($parts) + 1; $remapIgnored = true; while (--$k >= 0) { $part = $parts[$k]; if ($part instanceof AbstractPart) { break; } if ($this->isFollowedByLastnamePart($parts, $k)) { if ($mapped = $this->mapAsPrefixIfPossible($parts, $k)) { $parts[$k] = $mapped; continue; } if ($this->shouldStopMapping($parts, $k)) { break; } } $parts[$k] = new Lastname($part); $remapIgnored = false; } if ($remapIgnored) { $parts = $this->remapIgnored($parts); } return $parts; } /** * try to map this part as a lastname prefix or as a combined * lastname part containing a prefix * * @param array $parts * @param int $k * @return Lastname|null */ private function mapAsPrefixIfPossible(array $parts, int $k): ?Lastname { if ($this->isApplicablePrefix($parts, $k)) { return new LastnamePrefix($parts[$k], $this->prefixes[$this->getKey($parts[$k])]); } if ($this->isCombinedWithPrefix($parts[$k])) { return new Lastname($parts[$k]); } return null; } /** * check if the given part is a combined lastname part * that ends in a lastname prefix * * @param string $part * @return bool */ private function isCombinedWithPrefix(string $part): bool { $pos = strpos($part, '-'); if (false === $pos) { return false; } return $this->isPrefix(substr($part, $pos + 1)); } /** * skip through the parts we want to ignore and return the start index * * @param array $parts * @return int */ protected function skipIgnoredParts(array $parts): int { $k = count($parts); while (--$k >= 0) { if (!$this->isIgnoredPart($parts[$k])) { break; } } return $k; } /** * indicates if we should stop mapping at the given index $k * * the assumption is that lastname parts have already been found * but we want to see if we should add more parts * * @param array $parts * @param int $k * @return bool */ protected function shouldStopMapping(array $parts, int $k): bool { if ($k < 1) { return true; } $lastPart = $parts[$k + 1]; if ($lastPart instanceof LastnamePrefix) { return true; } return strlen($lastPart->getValue()) >= 3; } /** * indicates if the given part should be ignored (skipped) during mapping * * @param $part * @return bool */ protected function isIgnoredPart($part) { return $part instanceof Suffix || $part instanceof Nickname || $part instanceof Salutation; } /** * remap ignored parts as lastname * * if the mapping did not derive any lastname this is called to transform * any previously ignored parts into lastname parts * * @param array $parts * @return array */ protected function remapIgnored(array $parts): array { $k = count($parts); while (--$k >= 0) { $part = $parts[$k]; if (!$this->isIgnoredPart($part)) { break; } $parts[$k] = new Lastname($part); } return $parts; } /** * @param array $parts * @param int $index * @return bool */ protected function isFollowedByLastnamePart(array $parts, int $index): bool { $next = $this->skipNicknameParts($parts, $index + 1); return (isset($parts[$next]) && $parts[$next] instanceof Lastname); } /** * Assuming that the part at the given index is matched as a prefix, * determines if the prefix should be applied to the lastname. * * We only apply it to the lastname if we already have at least one * lastname part and there are other parts left in * the name (this effectively prioritises firstname over prefix matching). * * This expects the parts array and index to be in the original order. * * @param array $parts * @param int $index * @return bool */ protected function isApplicablePrefix(array $parts, int $index): bool { if (!$this->isPrefix($parts[$index])) { return false; } return $this->hasUnmappedPartsBefore($parts, $index); } /** * check if the given word is a lastname prefix * * @param string $word the word to check * @return bool */ protected function isPrefix($word): bool { return (array_key_exists($this->getKey($word), $this->prefixes)); } /** * find the next non-nickname index in parts * * @param $parts * @param $startIndex * @return int|void */ protected function skipNicknameParts($parts, $startIndex) { $total = count($parts); for ($i = $startIndex; $i < $total; $i++) { if (!($parts[$i] instanceof Nickname)) { return $i; } } return $total - 1; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/InitialMapper.php
src/Mapper/InitialMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Initial; /** * single letter, possibly followed by a period */ class InitialMapper extends AbstractMapper { protected $matchLastPart = false; private $combinedMax = 2; public function __construct(int $combinedMax = 2, bool $matchLastPart = false) { $this->matchLastPart = $matchLastPart; $this->combinedMax = $combinedMax; } /** * map intials in parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { $last = count($parts) - 1; for ($k = 0; $k < count($parts); $k++) { $part = $parts[$k]; if ($part instanceof AbstractPart) { continue; } if (!$this->matchLastPart && $k === $last) { continue; } if (strtoupper($part) === $part) { $stripped = str_replace('.', '', $part); $length = strlen($stripped); if (1 < $length && $length <= $this->combinedMax) { array_splice($parts, $k, 1, str_split($stripped)); $last = count($parts) - 1; $part = $parts[$k]; } } if ($this->isInitial($part)) { $parts[$k] = new Initial($part); } } return $parts; } /** * @param string $part * @return bool */ protected function isInitial(string $part): bool { $length = strlen($part); if (1 === $length) { return true; } return ($length === 2 && substr($part, -1) === '.'); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/FirstnameMapper.php
src/Mapper/FirstnameMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\Initial; use TheIconic\NameParser\Part\Salutation; class FirstnameMapper extends AbstractMapper { /** * map firstnames in parts array * * @param array $parts the parts * @return array the mapped parts */ public function map(array $parts): array { if (count($parts) < 2) { return [$this->handleSinglePart($parts[0])]; } $pos = $this->findFirstnamePosition($parts); if (null !== $pos) { $parts[$pos] = new Firstname($parts[$pos]); } return $parts; } /** * @param $part * @return Firstname */ protected function handleSinglePart($part): AbstractPart { if ($part instanceof AbstractPart) { return $part; } return new Firstname($part); } /** * @param array $parts * @return int|null */ protected function findFirstnamePosition(array $parts): ?int { $pos = null; $length = count($parts); $start = $this->getStartIndex($parts); for ($k = $start; $k < $length; $k++) { $part = $parts[$k]; if ($part instanceof Lastname) { break; } if ($part instanceof Initial && null === $pos) { $pos = $k; } if ($part instanceof AbstractPart) { continue; } return $k; } return $pos; } /** * @param array $parts * @return int */ protected function getStartIndex(array $parts): int { $index = $this->findFirstMapped(Salutation::class, $parts); if (false === $index) { return 0; } if ($index === count($parts) - 1) { return 0; } return $index + 1; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/MiddlenameMapper.php
src/Mapper/MiddlenameMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\Middlename; class MiddlenameMapper extends AbstractMapper { protected $mapWithoutLastname = false; public function __construct(bool $mapWithoutLastname = false) { $this->mapWithoutLastname = $mapWithoutLastname; } /** * map middlenames in the parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { // If we don't expect a lastname, match a mimimum of 2 parts $minumumParts = ($this->mapWithoutLastname ? 2 : 3); if (count($parts) < $minumumParts) { return $parts; } $start = $this->findFirstMapped(Firstname::class, $parts); if (false === $start) { return $parts; } return $this->mapFrom($start, $parts); } /** * @param $start * @param $parts * @return mixed */ protected function mapFrom($start, $parts): array { // If we don't expect a lastname, include the last part, // otherwise skip the last (-1) because it should be a lastname $length = count($parts) - ($this->mapWithoutLastname ? 0 : 1); for ($k = $start; $k < $length; $k++) { $part = $parts[$k]; if ($part instanceof Lastname) { break; } if ($part instanceof AbstractPart) { continue; } $parts[$k] = new Middlename($part); } return $parts; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/NicknameMapper.php
src/Mapper/NicknameMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Nickname; class NicknameMapper extends AbstractMapper { /** * @var array */ protected $delimiters = [ '[' => ']', '{' => '}', '(' => ')', '<' => '>', '"' => '"', '\'' => '\'' ]; public function __construct(array $delimiters = []) { if (!empty($delimiters)) { $this->delimiters = $delimiters; } } /** * map nicknames in the parts array * * @param array $parts the name parts * @return array the mapped parts */ public function map(array $parts): array { $isEncapsulated = false; $regexp = $this->buildRegexp(); $closingDelimiter = ''; foreach ($parts as $k => $part) { if ($part instanceof AbstractPart) { continue; } if (preg_match($regexp, $part, $matches)) { $isEncapsulated = true; $part = substr($part, 1); $closingDelimiter = $this->delimiters[$matches[1]]; } if (!$isEncapsulated) { continue; } if ($closingDelimiter === substr($part, -1)) { $isEncapsulated = false; $part = substr($part, 0, -1); } $parts[$k] = new Nickname(str_replace(['"', '\''], '', $part)); } return $parts; } /** * @return string */ protected function buildRegexp() { $regexp = '/^(['; foreach ($this->delimiters as $opening => $closing) { $regexp .= sprintf('\\%s', $opening); } $regexp .= '])/'; return $regexp; } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/src/Mapper/AbstractMapper.php
src/Mapper/AbstractMapper.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\AbstractPart; use TheIconic\NameParser\Part\Nickname; abstract class AbstractMapper { /** * implements the mapping of parts * * @param array $parts - the name parts * @return array $parts - the mapped parts */ abstract public function map(array $parts); /** * checks if there are still unmapped parts left before the given position * * @param array $parts * @param $index * @return bool */ protected function hasUnmappedPartsBefore(array $parts, $index): bool { foreach ($parts as $k => $part) { if ($k === $index) { break; } if (!($part instanceof AbstractPart)) { return true; } } return false; } /** * @param string $type * @param array $parts * @return int|bool */ protected function findFirstMapped(string $type, array $parts) { $total = count($parts); for ($i = 0; $i < $total; $i++) { if ($parts[$i] instanceof $type) { return $i; } } return false; } /** * get the registry lookup key for the given word * * @param string $word the word * @return string the key */ protected function getKey($word): string { return strtolower(str_replace('.', '', $word)); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/NameTest.php
tests/NameTest.php
<?php namespace TheIconic\NameParser; use PHPUnit\Framework\TestCase; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Initial; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\LastnamePrefix; use TheIconic\NameParser\Part\Middlename; use TheIconic\NameParser\Part\Nickname; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Suffix; class NameTest extends TestCase { public function testToString() { $parts = [ new Salutation('Mr', 'Mr.'), new Firstname('James'), new Middlename('Morgan'), new Nickname('Jim'), new Initial('T.'), new Lastname('Smith'), new Suffix('I', 'I'), ]; $name = new Name($parts); $this->assertSame($parts, $name->getParts()); $this->assertSame('Mr. James (Jim) Morgan T. Smith I', (string) $name); } public function testGetNickname() { $name = new Name([ new Nickname('Jim'), ]); $this->assertSame('Jim', $name->getNickname()); $this->assertSame('(Jim)', $name->getNickname(true)); } public function testGettingLastnameAndLastnamePrefixSeparately() { $name = new Name([ new Firstname('Frank'), new LastnamePrefix('van'), new Lastname('Delft'), ]); $this->assertSame('Frank', $name->getFirstname()); $this->assertSame('van', $name->getLastnamePrefix()); $this->assertSame('Delft', $name->getLastname(true)); $this->assertSame('van Delft', $name->getLastname()); } public function testGetGivenNameShouldReturnGivenNameInGivenOrder(): void { $parser = new Parser(); $name = $parser->parse('Schuler, J. Peter M.'); $this->assertSame('J. Peter M.', $name->getGivenName()); } public function testGetFullNameShouldReturnTheFullNameInGivenOrder(): void { $parser = new Parser(); $name = $parser->parse('Schuler, J. Peter M.'); $this->assertSame('J. Peter M. Schuler', $name->getFullName()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/ParserTest.php
tests/ParserTest.php
<?php namespace TheIconic\NameParser; use PHPUnit\Framework\TestCase; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Language\German; class ParserTest extends TestCase { /** * @return array */ public function provider() { return [ [ 'James Norrington', [ 'firstname' => 'James', 'lastname' => 'Norrington', ] ], [ 'Hans Christian Anderssen', [ 'firstname' => 'Hans', 'lastname' => 'Anderssen', 'middlename' => 'Christian', ] ], [ 'Mr Anthony R Von Fange III', [ 'salutation' => 'Mr.', 'firstname' => 'Anthony', 'initials' => 'R', 'lastname' => 'von Fange', 'suffix' => 'III', ] ], [ 'J. B. Hunt', [ 'firstname' => 'J.', 'initials' => 'B.', 'lastname' => 'Hunt', ] ], [ 'J.B. Hunt', [ 'firstname' => 'J', 'initials' => 'B', 'lastname' => 'Hunt', ] ], [ 'Edward Senior III', [ 'firstname' => 'Edward', 'lastname' => 'Senior', 'suffix' => 'III' ] ], [ 'Edward Dale Senior II', [ 'firstname' => 'Edward', 'lastname' => 'Dale', 'suffix' => 'Senior II' ] ], [ 'Dale Edward Jones Senior', [ 'firstname' => 'Dale', 'middlename' => 'Edward', 'lastname' => 'Jones', 'suffix' => 'Senior' ] ], [ 'Jason Rodriguez Sr.', [ 'firstname' => 'Jason', 'lastname' => 'Rodriguez', 'suffix' => 'Sr' ] ], [ 'Jason Senior', [ 'firstname' => 'Jason', 'lastname' => 'Senior', ] ], [ 'Bill Junior', [ 'firstname' => 'Bill', 'lastname' => 'Junior', ] ], [ 'Sara Ann Fraser', [ 'firstname' => 'Sara', 'middlename' => 'Ann', 'lastname' => 'Fraser', ] ], [ 'Adam', [ 'firstname' => 'Adam', ] ], [ 'OLD MACDONALD', [ 'firstname' => 'Old', 'lastname' => 'Macdonald', ] ], [ 'Old MacDonald', [ 'firstname' => 'Old', 'lastname' => 'MacDonald', ] ], [ 'Old McDonald', [ 'firstname' => 'Old', 'lastname' => 'McDonald', ] ], [ 'Old Mc Donald', [ 'firstname' => 'Old', 'middlename' => 'Mc', 'lastname' => 'Donald', ] ], [ 'Old Mac Donald', [ 'firstname' => 'Old', 'middlename' => 'Mac', 'lastname' => 'Donald', ] ], [ 'James van Allen', [ 'firstname' => 'James', 'lastname' => 'van Allen', ] ], [ 'Jimmy (Bubba) Smith', [ 'firstname' => 'Jimmy', 'lastname' => 'Smith', 'nickname' => 'Bubba', ] ], [ 'Miss Jennifer Shrader Lawrence', [ 'salutation' => 'Miss', 'firstname' => 'Jennifer', 'middlename' => 'Shrader', 'lastname' => 'Lawrence', ] ], [ 'Dr. Jonathan Smith', [ 'salutation' => 'Dr.', 'firstname' => 'Jonathan', 'lastname' => 'Smith', ] ], [ 'Ms. Jamie P. Harrowitz', [ 'salutation' => 'Ms.', 'firstname' => 'Jamie', 'initials' => 'P.', 'lastname' => 'Harrowitz', ] ], [ 'Mr John Doe', [ 'salutation' => 'Mr.', 'firstname' => 'John', 'lastname' => 'Doe', ] ], [ 'Rev. Dr John Doe', [ 'salutation' => 'Rev. Dr.', 'firstname' => 'John', 'lastname' => 'Doe', ] ], [ 'Prof. Tyson J. Hirthe', [ 'salutation' => 'Prof.', 'lastname' => 'Hirthe', 'firstname' => 'Tyson', 'initials' => 'J.', ] ], [ 'prof Eveline Aufderhar', [ 'salutation' => 'Prof.', 'lastname' => 'Aufderhar', 'firstname' => 'Eveline', ] ], [ 'Anthony Von Fange III', [ 'firstname' => 'Anthony', 'lastname' => 'von Fange', 'suffix' => 'III' ] ], [ 'Smarty Pants Phd', [ 'firstname' => 'Smarty', 'lastname' => 'Pants', 'suffix' => 'PhD' ] ], [ 'Mark Peter Williams', [ 'firstname' => 'Mark', 'middlename' => 'Peter', 'lastname' => 'Williams', ] ], [ 'Mark P Williams', [ 'firstname' => 'Mark', 'lastname' => 'Williams', 'initials' => 'P', ] ], [ 'Mark P. Williams', [ 'firstname' => 'Mark', 'initials' => 'P.', 'lastname' => 'Williams', ] ], [ 'M Peter Williams', [ 'firstname' => 'Peter', 'initials' => 'M', 'lastname' => 'Williams', ] ], [ 'M. Peter Williams', [ 'firstname' => 'Peter', 'initials' => 'M.', 'lastname' => 'Williams', ] ], [ 'M. P. Williams', [ 'firstname' => 'M.', 'initials' => 'P.', 'lastname' => 'Williams', ] ], [ 'The Rev. Mark Williams', [ 'salutation' => 'Rev.', 'firstname' => 'Mark', 'lastname' => 'Williams', ] ], [ 'Mister Mark Williams', [ 'salutation' => 'Mr.', 'firstname' => 'Mark', 'lastname' => 'Williams', ] ], [ 'Fraser, Joshua', [ 'firstname' => 'Joshua', 'lastname' => 'Fraser', ] ], [ 'Mrs. Brown, Amanda', [ 'salutation' => 'Mrs.', 'firstname' => 'Amanda', 'lastname' => 'Brown', ] ], [ "Mr.\r\nPaul\rJoseph\nMaria\tWinters", [ 'salutation' => 'Mr.', 'firstname' => 'Paul', 'middlename' => 'Joseph Maria', 'lastname' => 'Winters', ] ], [ 'Van Truong', [ 'firstname' => 'Van', 'lastname' => 'Truong', ], ], [ 'John Van', [ 'firstname' => 'John', 'lastname' => 'Van', ], ], [ 'Mr. Van Truong', [ 'salutation' => 'Mr.', 'firstname' => 'Van', 'lastname' => 'Truong', ], ], [ 'Anthony Von Fange III, PHD', [ 'firstname' => 'Anthony', 'lastname' => 'von Fange', 'suffix' => 'III PhD' ] ], [ 'Jimmy (Bubba Junior) Smith', [ 'nickname' => 'Bubba Junior', 'firstname' => 'Jimmy', 'lastname' => 'Smith', ] ], [ 'Jonathan Smith, MD', [ 'firstname' => 'Jonathan', 'lastname' => 'Smith', 'suffix' => 'MD' ] ], [ 'Kirk, James T.', [ 'firstname' => 'James', 'initials' => 'T.', 'lastname' => 'Kirk', ], ], [ 'James B', [ 'firstname' => 'James', 'lastname' => 'B', ] ], [ 'Williams, Hank, Jr.', [ 'firstname' => 'Hank', 'lastname' => 'Williams', 'suffix' => 'Jr', ] ], [ 'Sir James Reynolds, Junior', [ 'salutation' => 'Sir', 'firstname' => 'James', 'lastname' => 'Reynolds', 'suffix' => 'Junior' ] ], [ 'Sir John Paul Getty Sr.', [ 'salutation' => 'Sir', 'firstname' => 'John', 'middlename' => 'Paul', 'lastname' => 'Getty', 'suffix' => 'Sr', ] ], [ 'etna übel', [ 'firstname' => 'Etna', 'lastname' => 'Übel', ] ], [ 'Markus Müller', [ 'firstname' => 'Markus', 'lastname' => 'Müller', ] ], [ 'Charles Dixon (20th century)', [ 'firstname' => 'Charles', 'lastname' => 'Dixon', 'nickname' => '20Th Century' ] ], [ 'Smith, John Eric', [ 'lastname' => 'Smith', 'firstname' => 'John', 'middlename' => 'Eric', ] ], [ 'PAUL M LEWIS MR', [ 'firstname' => 'Paul', 'initials' => 'M', 'lastname' => 'Lewis Mr', ] ], [ 'SUJAN MASTER', [ 'firstname' => 'Sujan', 'lastname' => 'Master', ], ], [ 'JAMES J MA', [ 'firstname' => 'James', 'initials' => 'J', 'lastname' => 'Ma', ] ], [ 'Tiptree, James, Jr.', [ 'lastname' => 'Tiptree', 'firstname' => 'James', 'suffix' => 'Jr', ] ], [ 'Miller, Walter M., Jr.', [ 'lastname' => 'Miller', 'firstname' => 'Walter', 'initials' => 'M.', 'suffix' => 'Jr', ] ], [ 'Tiptree, James Jr.', [ 'lastname' => 'Tiptree', 'firstname' => 'James', 'suffix' => 'Jr', ] ], [ 'Miller, Walter M. Jr.', [ 'lastname' => 'Miller', 'firstname' => 'Walter', 'initials' => 'M.', 'suffix' => 'Jr', ] ], [ 'Thái Quốc Nguyễn', [ 'lastname' => 'Nguyễn', 'middlename' => 'Quốc', 'firstname' => 'Thái', ] ], [ 'Yumeng Du', [ 'lastname' => 'Du', 'firstname' => 'Yumeng', ] ], [ 'Her Honour Mrs Judy', [ 'lastname' => 'Judy', 'salutation' => 'Her Honour Mrs.' ] ], [ 'Etje Heijdanus-De Boer', [ 'firstname' => 'Etje', 'lastname' => 'Heijdanus-De Boer', ] ], [ 'JB Hunt', [ 'firstname' => 'J', 'initials' => 'B', 'lastname' => 'Hunt', ] ], [ 'Charles Philip Arthur George Mountbatten-Windsor', [ 'firstname' => 'Charles', 'middlename' => 'Philip Arthur George', 'lastname' => 'Mountbatten-Windsor', ] ], [ 'Ella Marija Lani Yelich-O\'Connor', [ 'firstname' => 'Ella', 'middlename' => 'Marija Lani', 'lastname' => 'Yelich-O\'Connor', ] ] ]; } /** * @dataProvider provider * * @param $input * @param $expectation */ public function testParse($input, $expectation) { $parser = new Parser(); $name = $parser->parse($input); $this->assertInstanceOf(Name::class, $name); $this->assertEquals($expectation, $name->getAll()); } public function testSetGetWhitespace() { $parser = new Parser(); $parser->setWhitespace('abc'); $this->assertSame('abc', $parser->getWhitespace()); $parser->setWhitespace(' '); $this->assertSame(' ', $parser->getWhitespace()); $parser->setWhitespace(' _'); $this->assertSame(' _', $parser->getWhitespace()); } public function testSetGetNicknameDelimiters() { $parser = new Parser(); $parser->setNicknameDelimiters(['[' => ']']); $this->assertSame(['[' => ']'], $parser->getNicknameDelimiters()); $this->assertSame('Jim', $parser->parse('[Jim]')->getNickname()); $this->assertNotSame('Jim', $parser->parse('(Jim)')->getNickname()); } public function testSetMaxSalutationIndex() { $parser = new Parser(); $this->assertSame(0, $parser->getMaxSalutationIndex()); $parser->setMaxSalutationIndex(1); $this->assertSame(1, $parser->getMaxSalutationIndex()); $this->assertSame('', $parser->parse('Francis Mr')->getSalutation()); $parser = new Parser(); $this->assertSame(0, $parser->getMaxSalutationIndex()); $parser->setMaxSalutationIndex(2); $this->assertSame(2, $parser->getMaxSalutationIndex()); $this->assertSame('Mr.', $parser->parse('Francis Mr')->getSalutation()); } public function testSetMaxCombinedInitials() { $parser = new Parser(); $this->assertSame(2, $parser->getMaxCombinedInitials()); $parser->setMaxCombinedInitials(1); $this->assertSame(1, $parser->getMaxCombinedInitials()); $this->assertSame('', $parser->parse('DJ Westbam')->getInitials()); $parser = new Parser(); $this->assertSame(2, $parser->getMaxCombinedInitials()); $parser->setMaxCombinedInitials(3); $this->assertSame(3, $parser->getMaxCombinedInitials()); $this->assertSame('P A G', $parser->parse('Charles PAG Mountbatten-Windsor')->getInitials()); } public function testParserAndSubparsersProperlyHandleLanguages() { $parser = new Parser([ new German(), ]); $this->assertSame('Herr', $parser->parse('Herr Schmidt')->getSalutation()); $this->assertSame('Herr', $parser->parse('Herr Schmidt, Bernd')->getSalutation()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/GermanParserTest.php
tests/GermanParserTest.php
<?php namespace TheIconic\NameParser; use PHPUnit\Framework\TestCase; use TheIconic\NameParser\Language\German; class GermanParserTest extends TestCase { /** * @return array */ public function provider() { return [ [ 'Herr Schmidt', [ 'salutation' => 'Herr', 'lastname' => 'Schmidt', ] ], [ 'Frau Maria Lange', [ 'salutation' => 'Frau', 'firstname' => 'Maria', 'lastname' => 'Lange', ] ], [ 'Hr. Juergen von der Lippe', [ 'salutation' => 'Herr', 'firstname' => 'Juergen', 'lastname' => 'von der Lippe', ] ], [ 'Fr. Charlotte von Stein', [ 'salutation' => 'Frau', 'firstname' => 'Charlotte', 'lastname' => 'von Stein', ] ], ]; } /** * @dataProvider provider * * @param $input * @param $expectation */ public function testParse($input, $expectation) { $parser = new Parser([ new German() ]); $name = $parser->parse($input); $this->assertInstanceOf(Name::class, $name); $this->assertEquals($expectation, $name->getAll()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/bootstrap.php
tests/bootstrap.php
<?php use phpmock\phpunit\PHPMock; PHPMock::defineFunctionMock('TheIconic\NameParser\Part', 'function_exists'); require dirname(__DIR__) . '/vendor/autoload.php';
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Part/AbstractPartTest.php
tests/Part/AbstractPartTest.php
<?php namespace TheIconic\NameParser\Part; use PHPUnit\Framework\TestCase; class AbstractPartTest extends TestCase { /** * make sure the placeholder normalize() method returns the original value */ public function testNormalize() { $part = $this->getMockForAbstractClass(AbstractPart::class, ['abc']); $this->assertEquals('abc', $part->normalize()); } /** * make sure we unwrap any parts during setValue() calls */ public function testSetValueUnwraps() { $part = $this->getMockForAbstractClass(AbstractPart::class, ['abc']); $this->assertEquals('abc', $part->getValue()); $part = $this->getMockForAbstractClass(AbstractPart::class, [$part]); $this->assertEquals('abc', $part->getValue()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Part/NormalisationTest.php
tests/Part/NormalisationTest.php
<?php namespace TheIconic\NameParser\Part; use phpmock\phpunit\PHPMock; use PHPUnit\Framework\TestCase; class NormalisationTest extends TestCase { use PHPMock; /** * make sure we test both with and without mb_string support */ public function testCamelcasingWorksWithMbString() { $functionExistsMock = $this->getFunctionMock(__NAMESPACE__, 'function_exists'); $functionExistsMock->expects($this->any()) ->with('mb_convert_case') ->willReturn(true); $part = new Lastname('McDonald'); $this->assertEquals('McDonald', $part->normalize()); $part = new Lastname('übel'); $this->assertEquals('Übel', $part->normalize()); $part = new Firstname('Anne-Marie'); $this->assertEquals('Anne-Marie', $part->normalize()); $part = new Firstname('etna'); $this->assertEquals('Etna', $part->normalize()); $part = new Firstname('thái'); $this->assertEquals('Thái', $part->normalize()); $part = new Lastname('nguyễn'); $this->assertEquals('Nguyễn', $part->normalize()); } /** * make sure we test both with and without mb_string support */ public function testCamelcasingWorksWithoutMbString() { $functionExistsMock = $this->getFunctionMock(__NAMESPACE__, 'function_exists'); $functionExistsMock->expects($this->any()) ->with('mb_convert_case') ->willReturn(false); $part = new Lastname('McDonald'); $this->assertEquals('McDonald', $part->normalize()); $part = new Lastname('ubel'); $this->assertEquals('Ubel', $part->normalize()); $part = new Firstname('Anne-Marie'); $this->assertEquals('Anne-Marie', $part->normalize()); $part = new Firstname('etna'); $this->assertEquals('Etna', $part->normalize()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/InitialMapperTest.php
tests/Mapper/InitialMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Part\Initial; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Lastname; class InitialMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'A', 'B', ], 'expectation' => [ new Initial('A'), 'B', ], ], [ 'input' => [ new Salutation('Mr'), 'P.', 'Pan', ], 'expectation' => [ new Salutation('Mr'), new Initial('P.'), 'Pan', ], ], [ 'input' => [ new Salutation('Mr'), 'Peter', 'D.', new Lastname('Pan'), ], 'expectation' => [ new Salutation('Mr'), 'Peter', new Initial('D.'), new Lastname('Pan'), ], ], [ 'input' => [ 'James', 'B' ], 'expectation' => [ 'James', 'B' ], ], [ 'input' => [ 'James', 'B' ], 'expectation' => [ 'James', new Initial('B'), ], 'arguments' => [ 2, true ], ], [ 'input' => [ 'JM', 'Walker', ], 'expectation' => [ new Initial('J'), new Initial('M'), 'Walker' ] ], [ 'input' => [ 'JM', 'Walker', ], 'expectation' => [ 'JM', 'Walker' ], 'arguments' => [ 1 ] ] ]; } protected function getMapper($maxCombined = 2, $matchLastPart = false) { return new InitialMapper($maxCombined, $matchLastPart); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/LastnameMapperTest.php
tests/Mapper/LastnameMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\LastnamePrefix; class LastnameMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'Peter', 'Pan', ], 'expectation' => [ 'Peter', new Lastname('Pan'), ], ], [ 'input' => [ new Salutation('Mr'), 'Peter', 'Pan', ], 'expectation' => [ new Salutation('Mr'), 'Peter', new Lastname('Pan'), ], ], [ 'input' => [ new Salutation('Mr'), new Firstname('Peter'), 'Pan', ], 'expectation' => [ new Salutation('Mr'), new Firstname('Peter'), new Lastname('Pan'), ], ], [ 'input' => [ new Salutation('Mr'), 'Lars', 'van', 'Trier', ], 'expectation' => [ new Salutation('Mr'), 'Lars', new LastnamePrefix('van'), new Lastname('Trier'), ], ], [ 'input' => [ new Salutation('Mr'), 'Dan', 'Huong', ], 'expectation' => [ new Salutation('Mr'), 'Dan', new Lastname('Huong'), ], ], [ 'input' => [ new Salutation('Mr'), 'Von', ], 'expectation' => [ new Salutation('Mr'), new Lastname('Von'), ], ], [ 'input' => [ 'Mr', 'Von', ], 'expectation' => [ 'Mr', new Lastname('Von'), ], ], [ 'input' => [ 'Kirk' ], 'expectation' => [ 'Kirk' ], ], [ 'input' => [ 'Kirk', ], 'expectation' => [ new Lastname('Kirk'), ], 'arguments' => [ true ], ] ]; } protected function getMapper($matchSingle = false) { $english = new English(); return new LastnameMapper($english->getLastnamePrefixes(), $matchSingle); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/AbstractMapperTest.php
tests/Mapper/AbstractMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use PHPUnit\Framework\TestCase; abstract class AbstractMapperTest extends TestCase { /** * @dataProvider provider * * @param $input * @param $expectation */ public function testMap($input, $expectation, $arguments = []) { $mapper = call_user_func_array([$this, 'getMapper'], $arguments); $this->assertEquals($expectation, $mapper->map($input)); } abstract protected function getMapper(); }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/MiddlenameMapperTest.php
tests/Mapper/MiddlenameMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Middlename; use TheIconic\NameParser\Part\Lastname; class MiddlenameMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ new Firstname('Peter'), 'Fry', new Lastname('Pan'), ], 'expectation' => [ new Firstname('Peter'), new Middlename('Fry'), new Lastname('Pan'), ], ], [ 'input' => [ new Firstname('John'), 'Albert', 'Tiberius', new Lastname('Brown'), ], 'expectation' => [ new Firstname('John'), new Middlename('Albert'), new Middlename('Tiberius'), new Lastname('Brown'), ], ], [ 'input' => [ 'Mr', new Firstname('James'), 'Tiberius', 'Kirk', ], 'expectation' => [ 'Mr', new Firstname('James'), new Middlename('Tiberius'), 'Kirk', ], ], [ 'input' => [ 'James', 'Tiberius', 'Kirk', ], 'expectation' => [ 'James', 'Tiberius', 'Kirk', ], ], [ 'input' => [ 'Albert', 'Einstein', ], 'expectation' => [ 'Albert', 'Einstein', ], ], [ 'input' => [ new Firstname('James'), 'Tiberius', ], 'expectation' => [ new Firstname('James'), new Middlename('Tiberius'), ], 'arguments' => [ true ], ], ]; } protected function getMapper($mapWithoutLastname = false) { return new MiddlenameMapper($mapWithoutLastname); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/SuffixMapperTest.php
tests/Mapper/SuffixMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Part\Lastname; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Suffix; class SuffixMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'Mr.', 'James', 'Blueberg', 'PhD', ], 'expectation' => [ 'Mr.', 'James', 'Blueberg', new Suffix('PhD'), ], [ 'matchSinglePart' => false, 'reservedParts' => 2, ] ], [ 'input' => [ 'Prince', 'Alfred', 'III', ], 'expectation' => [ 'Prince', 'Alfred', new Suffix('III'), ], [ 'matchSinglePart' => false, 'reservedParts' => 2, ] ], [ 'input' => [ new Firstname('Paul'), new Lastname('Smith'), 'Senior', ], 'expectation' => [ new Firstname('Paul'), new Lastname('Smith'), new Suffix('Senior'), ], [ 'matchSinglePart' => false, 'reservedParts' => 2, ] ], [ 'input' => [ 'Senior', new Firstname('James'), 'Norrington', ], 'expectation' => [ 'Senior', new Firstname('James'), 'Norrington', ], [ 'matchSinglePart' => false, 'reservedParts' => 2, ] ], [ 'input' => [ 'Senior', new Firstname('James'), new Lastname('Norrington'), ], 'expectation' => [ 'Senior', new Firstname('James'), new Lastname('Norrington'), ], [ 'matchSinglePart' => false, 'reservedParts' => 2, ] ], [ 'input' => [ 'James', 'Norrington', 'Senior', ], 'expectation' => [ 'James', 'Norrington', new Suffix('Senior'), ], [ false, 2, ] ], [ 'input' => [ 'Norrington', 'Senior', ], 'expectation' => [ 'Norrington', 'Senior', ], [ false, 2, ] ], [ 'input' => [ new Lastname('Norrington'), 'Senior', ], 'expectation' => [ new Lastname('Norrington'), new Suffix('Senior'), ], [ false, 1, ] ], [ 'input' => [ 'Senior', ], 'expectation' => [ new Suffix('Senior'), ], [ true, ] ], ]; } protected function getMapper($matchSinglePart = false, $reservedParts = 2) { $english = new English(); return new SuffixMapper($english->getSuffixes(), $matchSinglePart, $reservedParts); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/FirstnameMapperTest.php
tests/Mapper/FirstnameMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Lastname; class FirstnameMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'Peter', 'Pan', ], 'expectation' => [ new Firstname('Peter'), 'Pan', ], ], [ 'input' => [ new Salutation('Mr'), 'Peter', 'Pan', ], 'expectation' => [ new Salutation('Mr'), new Firstname('Peter'), 'Pan', ], ], [ 'input' => [ new Salutation('Mr'), 'Peter', new Lastname('Pan'), ], 'expectation' => [ new Salutation('Mr'), new Firstname('Peter'), new Lastname('Pan'), ], ], [ 'input' => [ 'Alfonso', new Salutation('Mr'), ], 'expectation' => [ new Firstname('Alfonso'), new Salutation('Mr'), ] ] ]; } protected function getMapper() { return new FirstnameMapper(); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/SalutationMapperTest.php
tests/Mapper/SalutationMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Language\English; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Firstname; use TheIconic\NameParser\Part\Lastname; class SalutationMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'Mr.', 'Pan', ], 'expectation' => [ new Salutation('Mr.', 'Mr.'), 'Pan', ], ], [ 'input' => [ 'Mr', 'Peter', 'Pan', ], 'expectation' => [ new Salutation('Mr', 'Mr.'), 'Peter', 'Pan', ], ], [ 'input' => [ 'Mr', new Firstname('James'), 'Miss', ], 'expectation' => [ new Salutation('Mr', 'Mr.'), new Firstname('James'), 'Miss', ], ], ]; } protected function getMapper() { $english = new English(); return new SalutationMapper($english->getSalutations()); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
theiconic/name-parser
https://github.com/theiconic/name-parser/blob/8da40c7c093740f3514f826ead7d403fdc3ccb64/tests/Mapper/NicknameMapperTest.php
tests/Mapper/NicknameMapperTest.php
<?php namespace TheIconic\NameParser\Mapper; use TheIconic\NameParser\Part\Salutation; use TheIconic\NameParser\Part\Nickname; class NicknameMapperTest extends AbstractMapperTest { /** * @return array */ public function provider() { return [ [ 'input' => [ 'James', '(Jim)', 'T.', 'Kirk', ], 'expectation' => [ 'James', new Nickname('Jim'), 'T.', 'Kirk', ], ], [ 'input' => [ 'James', '(\'Jim\')', 'T.', 'Kirk', ], 'expectation' => [ 'James', new Nickname('Jim'), 'T.', 'Kirk', ], ], [ 'input' => [ 'William', '"Will"', 'Shatner', ], 'expectation' => [ 'William', new Nickname('Will'), 'Shatner', ], ], [ 'input' => [ new Salutation('Mr'), 'Andre', '(The', 'Giant)', 'Rene', 'Roussimoff', ], 'expectation' => [ new Salutation('Mr'), 'Andre', new Nickname('The'), new Nickname('Giant'), 'Rene', 'Roussimoff', ], ], [ 'input' => [ new Salutation('Mr'), 'Andre', '["The', 'Giant"]', 'Rene', 'Roussimoff', ], 'expectation' => [ new Salutation('Mr'), 'Andre', new Nickname('The'), new Nickname('Giant'), 'Rene', 'Roussimoff', ], ], [ 'input' => [ new Salutation('Mr'), 'Andre', '"The', 'Giant"', 'Rene', 'Roussimoff', ], 'expectation' => [ new Salutation('Mr'), 'Andre', new Nickname('The'), new Nickname('Giant'), 'Rene', 'Roussimoff', ], ], ]; } protected function getMapper() { return new NicknameMapper([ '[' => ']', '{' => '}', '(' => ')', '<' => '>', '"' => '"', '\'' => '\'' ]); } }
php
MIT
8da40c7c093740f3514f826ead7d403fdc3ccb64
2026-01-05T05:17:23.809919Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/server.php
server.php
<?php /** * Laravel - A PHP Framework For Web Artisans * * @author Taylor Otwell <taylor@laravel.com> */ $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { return false; } require_once __DIR__.'/public/index.php';
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Exceptions/Handler.php
app/Exceptions/Handler.php
<?php namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; /** * @psalm-suppress UndefinedClass */ class Handler extends ExceptionHandler { /** * A list of exception types with their corresponding custom log levels. * * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*> */ protected $levels = [ // ]; /** * A list of the inputs that are never flashed to the session on validation exceptions. * * @var array<int, string> */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * Register the exception handling callbacks for the application. * * @return void */ public function register() { $this->reportable(function (Throwable $e) { // }); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Kernel.php
app/Http/Kernel.php
<?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ /** * @psalm-suppress UndefinedClass * @psalm-suppress MissingDependency */ protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; /** * The application's route middleware groups. * * @var array */ protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Livewire/AdminController.php
app/Http/Livewire/AdminController.php
<?php namespace App\Http\Livewire; use Livewire\Component; class AdminController extends Component { /** * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ public function render() { return view('livewire.admin-controller'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Livewire/SearchVelflix.php
app/Http/Livewire/SearchVelflix.php
<?php namespace App\Http\Livewire; use Illuminate\Support\Facades\Http; use Livewire\Component; /** * @psalm-suppress UndefinedClass */ class SearchVelflix extends Component { public ?string $searchVelflix = ''; /** * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ public function render() { $searchVelflixResults = []; // @phpstan-ignore-next-line if (strlen($this->searchVelflix >= 3)) { $searchVelflixResults = Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/search/movie?query='.$this->searchVelflix) ->json()['results']; } // dump($searchVelflixResults); return view('livewire.search-velflix', [ // @phpstan-ignore-next-line 'searchVelflixResults' => collect($searchVelflixResults)->take(7), ]); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/Controller.php
app/Http/Controllers/Controller.php
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/NewsletterController.php
app/Http/Controllers/NewsletterController.php
<?php namespace App\Http\Controllers; use App\Services\Newsletter; use Exception; use Illuminate\Validation\ValidationException; class NewsletterController extends Controller { /** * @param \App\Services\Newsletter $newsletter * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function __invoke(Newsletter $newsletter) { request()->validate(['email' => 'required|email']); try { $newsletter->subscribe(request('email')); } catch (Exception $e) { throw ValidationException::withMessages([ 'email' => 'THis email could not be added to our newsletter.', ]); } return redirect('/')->with('success', 'You are now signed up to our newsletter!'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/VelflixController.php
app/Http/Controllers/VelflixController.php
<?php namespace App\Http\Controllers; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; class VelflixController extends Controller { /** * @param mixed $genreId * @return mixed */ private function getMoviesByGenre($genreId) { return Cache::remember('movies_genre_'.$genreId, 60 * 60, function () use ($genreId) { return Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/discover/movie', [ 'with_genres' => $genreId, ])->json()['results']; }); } public function index(): View|Factory { $popular = Cache::remember('movies_popular', 60 * 60, function () { return Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/movie/popular') ->json()['results']; }); $trending = Cache::remember('movies_trending', 60 * 60, function () { return Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/trending/movie/day') ->json()['results']; }); $velflixgenres = Cache::remember('movies_genres', 60 * 60, function () { return Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/genre/movie/list') ->json()['genres']; }); $comedies = $this->getMoviesByGenre(35); $action = $this->getMoviesByGenre(28); $western = $this->getMoviesByGenre(37); $horror = $this->getMoviesByGenre(27); $thriller = $this->getMoviesByGenre(53); $animation = $this->getMoviesByGenre(16); /** @psalm-suppress UndefinedClass **/ $genres = collect($velflixgenres)->mapWithKeys(function ($genre) { /** @phpstan-ignore-line */ return [$genre['id'] => $genre['name']]; }); return view('main', [ 'popular' => $popular, 'genres' => $genres, 'trending' => $trending, 'comedies' => $comedies, 'western' => $western, 'action' => $action, 'horror' => $horror, 'thriller' => $thriller, 'animation' => $animation, ]); } /** * @param mixed $id * @return View|Factory */ public function show($id): View|Factory { $playMovie = Cache::remember('movie_'.$id, 3600, function () use ($id) { return Http::withToken(config('services.tmdb.token')) ->get('https://api.themoviedb.org/3/movie/'.$id.'?append_to_response=credits,videos,images') ->json(); }); return view('components.movies.show', [ 'movies' => $playMovie, ]); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/SessionsController.php
app/Http/Controllers/SessionsController.php
<?php namespace App\Http\Controllers; use Illuminate\Validation\ValidationException; class SessionsController extends Controller { /** * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ public function create() { return view('auth.login'); } /** * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function store() { // Validate the request $attributes = request()->validate([ 'email' => ['required', 'email'], 'password' => ['required'], ]); // attempt to authenticate and log in the user // based on the provided credentials if (auth()->attempt($attributes)) { session()->regenerate(); return redirect('/movies')->with('success', 'Welcome '); } // auth filed throw ValidationException::withMessages([ 'email' => 'Your provieded credentials could not be verified.', ]); } /** * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function destroy() { // ddd('log the use out'); auth()->logout(); return redirect('/')->with('success', 'you\'re out'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/LoginController.php
app/Http/Controllers/LoginController.php
<?php namespace App\Http\Controllers; use App\Models\User; use Laravel\Socialite\Facades\Socialite; class LoginController extends Controller { /** * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function redirectToProvider() { return Socialite::driver('google')->redirect(); } /** * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function handleProviderCallback() { $googleUser = Socialite::driver('google')->user(); // dd($googleuser); $user = User::firstOrCreate( [ 'provider_id' => $googleUser->getId(), ], [ 'email' => $googleUser->getEmail(), 'name' => $googleUser->getName(), ] ); // Log the user in auth()->login($user); // Redirect to movies return redirect('/movies')->with('success', 'Your account has been created'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Controllers/RegisterController.php
app/Http/Controllers/RegisterController.php
<?php namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Validation\Rule; class RegisterController extends Controller { /** * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ public function create() { return view('auth.register'); } /** * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function store() { // return request()->all(); // create the user $attributes = request()->validate([ 'name' => ['required', 'max:255'], 'username' => ['required', 'min:3', 'max:255', Rule::unique('users', 'username')], 'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')], 'password' => ['required', 'min:7', 'max:255'], ]); $user = User::create($attributes); // log the user in auth()->login($user); // dd('success validation succeded'); return redirect('/movies')->with('success', 'Your account has been created'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/Authenticate.php
app/Http/Middleware/Authenticate.php
<?php namespace App\Http\Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware; class Authenticate extends Middleware { /** * Get the path the user should be redirected to when they are not authenticated. * * @param \Illuminate\Http\Request $request * @return string|null */ protected function redirectTo($request) { if (! $request->expectsJson()) { return route('login'); } } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/RedirectIfAuthenticated.php
app/Http/Middleware/RedirectIfAuthenticated.php
<?php namespace App\Http\Middleware; use App\Providers\RouteServiceProvider; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null ...$guards * @return mixed */ public function handle(Request $request, Closure $next, ...$guards) { $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/TrustProxies.php
app/Http/Middleware/TrustProxies.php
<?php namespace App\Http\Middleware; use Illuminate\Http\Middleware\TrustProxies as Middleware; use Illuminate\Http\Request; /** * @psalm-suppress UndefinedClass */ class TrustProxies extends Middleware { /** * The trusted proxies for this application. * * @var array<int, string>|string|null */ protected $proxies; /** * The headers that should be used to detect proxies. * * @var int */ protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/PreventRequestsDuringMaintenance.php
app/Http/Middleware/PreventRequestsDuringMaintenance.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array */ protected $except = [ // ]; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/TrimStrings.php
app/Http/Middleware/TrimStrings.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. * * @var array */ protected $except = [ 'current_password', 'password', 'password_confirmation', ]; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/TrustHosts.php
app/Http/Middleware/TrustHosts.php
<?php namespace App\Http\Middleware; use Illuminate\Http\Middleware\TrustHosts as Middleware; class TrustHosts extends Middleware { /** * Get the host patterns that should be trusted. * * @return array */ public function hosts() { return [ $this->allSubdomainsOfApplicationUrl(), ]; } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/EncryptCookies.php
app/Http/Middleware/EncryptCookies.php
<?php namespace App\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; class EncryptCookies extends Middleware { /** * The names of the cookies that should not be encrypted. * * @var array */ protected $except = [ // ]; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Http/Middleware/VerifyCsrfToken.php
app/Http/Middleware/VerifyCsrfToken.php
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ // ]; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Services/Newsletter.php
app/Services/Newsletter.php
<?php namespace App\Services; use MailchimpMarketing\ApiClient; class Newsletter { /** * @param string $email * @param string|null $list * @return mixed */ public function subscribe(string $email, string $list = null) { $list ??= config('services.mailchimp.lists.subscribers'); // @phpstan-ignore-next-line return $this->client()->lists->addListMember($list, [ 'email_address' => $email, 'status' => 'subscribed', ]); } /** * @return \MailchimpMarketing\ApiClient */ protected function client() { return (new ApiClient() )->setConfig([ 'apiKey' => config('services.mailchimp.key'), 'server' => 'us5', ]); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Console/Kernel.php
app/Console/Kernel.php
<?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ // ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule->command('inspire')->hourly(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Models/User.php
app/Models/User.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; class User extends Authenticatable { use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var string[] */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', ]; // Mutators /** * @param mixed $password * @return void */ public function setPasswordAttribute($password) { $this->attributes['password'] = bcrypt($password); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Providers/BroadcastServiceProvider.php
app/Providers/BroadcastServiceProvider.php
<?php namespace App\Providers; use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Broadcast::routes(); require base_path('routes/channels.php'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Providers/RouteServiceProvider.php
app/Providers/RouteServiceProvider.php
<?php namespace App\Providers; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { /** * The path to the "home" route for your application. * * This is used by Laravel authentication to redirect users after login. * * @var string */ public const HOME = '/movies'; /** * Define your route model bindings, pattern filters, etc. * * @return void */ public function boot() { $this->configureRateLimiting(); $this->routes(function () { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); }); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Providers/EventServiceProvider.php
app/Providers/EventServiceProvider.php
<?php namespace App\Providers; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], ]; /** * Register any events for your application. * * @return void */ public function boot() { // } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Providers/AppServiceProvider.php
app/Providers/AppServiceProvider.php
<?php namespace App\Providers; use App\Models\User; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { // } /** * Bootstrap any application services. * * @return void */ public function boot() { Gate::define('admin', function (User $user) { return $user->username === 'admin'; }); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/Providers/AuthServiceProvider.php
app/Providers/AuthServiceProvider.php
<?php namespace App\Providers; // use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider { /** * The model to policy mappings for the application. * * @var array<class-string, class-string> */ protected $policies = [ // 'App\Models\Model' => 'App\Policies\ModelPolicy', ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); // } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/app/View/Components/velflixCard.php
app/View/Components/velflixCard.php
<?php namespace App\View\Components; use Illuminate\View\Component; class velflixCard extends Component { /** @var mixed */ public $velflix; /** * @param mixed $movie * @return void */ public function __construct($movie) { $this->velflix = $movie; } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|\Closure|string */ public function render() { return view('components.velflix-card'); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/bootstrap/app.php
bootstrap/app.php
<?php /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | The first thing we will do is create a new Laravel application instance | which serves as the "glue" for all the components of Laravel, and is | the IoC container for the system binding all of the various parts. | */ $app = new Illuminate\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) ); /* |-------------------------------------------------------------------------- | Bind Important Interfaces |-------------------------------------------------------------------------- | | Next, we need to bind some important interfaces into the container so | we will be able to resolve them when needed. The kernels serve the | incoming requests to this application from both the web and CLI. | */ $app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class ); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app;
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/Pest.php
tests/Pest.php
<?php /* |-------------------------------------------------------------------------- | Test Case |-------------------------------------------------------------------------- | | The closure you provide to your test functions is always bound to a specific PHPUnit test | case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may | need to change it using the "uses()" function to bind a different classes or traits. | */ uses(Tests\TestCase::class)->in('Feature'); /* |-------------------------------------------------------------------------- | Expectations |-------------------------------------------------------------------------- | | When you're writing tests, you often need to check that values meet certain conditions. The | "expect()" function gives you access to a set of "expectations" methods that you can use | to assert different things. Of course, you may extend the Expectation API at any time. | */ expect()->extend('toBeOne', function () { return $this->toBe(1); }); /* |-------------------------------------------------------------------------- | Functions |-------------------------------------------------------------------------- | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your | project that you don't want to repeat in every file. Here you can also expose helpers as | global functions to help you to reduce the number of lines of code in your test files. | */ function something() { // .. }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/TestCase.php
tests/TestCase.php
<?php namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/CreatesApplication.php
tests/CreatesApplication.php
<?php namespace Tests; use Illuminate\Contracts\Console\Kernel; trait CreatesApplication { /** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); return $app; } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/ExampleTest.php
tests/ExampleTest.php
<?php test('example', function () { expect(true)->toBeTrue(); });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/Feature/AuthenticationTest.php
tests/Feature/AuthenticationTest.php
<?php test('Test login screen can be rendered')->get('/login')->assertStatus(200); test('Test users can authenticate using the login screen', function () { $response = $this->post('/login', [ 'email' => 'user@gmail.com', 'password' => 'password', ]); $this->assertAuthenticated(); $response->assertRedirect('/movies'); });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/Feature/RegistrationTest.php
tests/Feature/RegistrationTest.php
<?php use Illuminate\Foundation\Testing\RefreshDatabase; uses(RefreshDatabase::class); test('test registration screen can berendered')->get('/register')->assertStatus(200); test('test new users can register', function () { $response = $this->post('/register', [ 'name' => 'User Test', 'username' => 'userTest', 'email' => 'test@example.com', 'password' => 'testpassword', ]); $this->assertAuthenticated(); $response->assertRedirect('/movies'); });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/tests/Unit/ExampleTest.php
tests/Unit/ExampleTest.php
<?php namespace Tests\Unit; use PHPUnit\Framework\TestCase; class ExampleTest extends TestCase { /** * A basic test example. * * @return void */ public function testBasicTest() { $this->assertTrue(true); } }
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/routes/web.php
routes/web.php
<?php use App\Http\Controllers\LoginController; use App\Http\Controllers\NewsletterController; use App\Http\Controllers\RegisterController; use App\Http\Controllers\SessionsController; use App\Http\Controllers\VelflixController; use Illuminate\Support\Facades\Route; Route::view('/', 'home'); Route::post('newsletter', NewsletterController::class); Route::middleware('guest')->group(function () { Route::get('login', [SessionsController::class, 'create'])->name('login'); Route::post('login', [SessionsController::class, 'store']); Route::get('register', [RegisterController::class, 'create'])->name('register'); Route::post('register', [RegisterController::class, 'store']); }); Route::middleware('auth')->group(function () { Route::post('logout', [SessionsController::class, 'destroy'])->name('logout'); Route::get('/movies', [VelflixController::class, 'index'])->name('velflix.index'); Route::get('/movie/{watch}', [VelflixController::class, 'show'])->name('movies.show'); }); Route::controller(LoginController::class)->group(function () { Route::get('login/google', 'redirectToProvider'); Route::get('login/google/callback', 'handleProviderCallback'); }); Route::middleware('can:admin')->group(function () { Route::view('admin', 'livewire.admin-controller'); });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/routes/channels.php
routes/channels.php
<?php use Illuminate\Support\Facades\Broadcast; /* |-------------------------------------------------------------------------- | Broadcast Channels |-------------------------------------------------------------------------- | | Here you may register all of the event broadcasting channels that your | application supports. The given channel authorization callbacks are | used to check if an authenticated user can listen to the channel. | */ Broadcast::channel('App.Models.User.{id}', function ($user, $id) { return (int) $user->id === (int) $id; });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/routes/api.php
routes/api.php
<?php use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | API Routes |-------------------------------------------------------------------------- | | Here is where you can register API routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | is assigned the "api" middleware group. Enjoy building your API! | */ Route::middleware('auth:api')->get('/user', function (Request $request) { return $request->user(); });
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/routes/console.php
routes/console.php
<?php use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; /* |-------------------------------------------------------------------------- | Console Routes |-------------------------------------------------------------------------- | | This file is where you may define all of your Closure based console | commands. Each Closure is bound to a command instance allowing a | simple approach to interacting with each command's IO methods. | */ Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote');
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/public/index.php
public/index.php
<?php use Illuminate\Contracts\Http\Kernel; use Illuminate\Http\Request; define('LARAVEL_START', microtime(true)); /* |-------------------------------------------------------------------------- | Check If The Application Is Under Maintenance |-------------------------------------------------------------------------- | | If the application is in maintenance / demo mode via the "down" command | we will load this file so that any pre-rendered content can be shown | instead of starting the framework, which could cause an exception. | */ if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) { require __DIR__.'/../storage/framework/maintenance.php'; } /* |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | this application. We just need to utilize it! We'll simply require it | into the script here so we don't need to manually load our classes. | */ require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request using | the application's HTTP kernel. Then, we will send the response back | to this client's browser, allowing them to enjoy our application. | */ $app = require_once __DIR__.'/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); $response = tap($kernel->handle( $request = Request::capture() ))->send(); $kernel->terminate($request, $response);
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/app.php
config/app.php
<?php return [ /* |-------------------------------------------------------------------------- | Application Name |-------------------------------------------------------------------------- | | This value is the name of your application. This value is used when the | framework needs to place the application's name in a notification or | any other location as required by the application or its packages. | */ 'name' => env('APP_NAME', 'Laravel'), /* |-------------------------------------------------------------------------- | Application Environment |-------------------------------------------------------------------------- | | This value determines the "environment" your application is currently | running in. This may determine how you prefer to configure various | services the application utilizes. Set this in your ".env" file. | */ 'env' => env('APP_ENV', 'production'), /* |-------------------------------------------------------------------------- | Application Debug Mode |-------------------------------------------------------------------------- | | When your application is in debug mode, detailed error messages with | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | */ 'debug' => (bool) env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | */ 'url' => env('APP_URL', 'http://localhost'), 'asset_url' => env('ASSET_URL', null), /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => 'en', /* |-------------------------------------------------------------------------- | Application Fallback Locale |-------------------------------------------------------------------------- | | The fallback locale determines the locale to use when the current one | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | */ 'fallback_locale' => 'en', /* |-------------------------------------------------------------------------- | Faker Locale |-------------------------------------------------------------------------- | | This locale will be used by the Faker PHP library when generating fake | data for your database seeds. For example, this will be used to get | localized telephone numbers, street address information and more. | */ 'faker_locale' => 'en_US', /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ], /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Arr' => Illuminate\Support\Arr::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Date' => Illuminate\Support\Facades\Date::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Http' => Illuminate\Support\Facades\Http::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, // 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'Str' => Illuminate\Support\Str::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/logging.php
config/logging.php
<?php use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; return [ /* |-------------------------------------------------------------------------- | Default Log Channel |-------------------------------------------------------------------------- | | This option defines the default log channel that gets used when writing | messages to the logs. The name specified in this option should match | one of the channels defined in the "channels" configuration array. | */ 'default' => env('LOG_CHANNEL', 'stack'), /* |-------------------------------------------------------------------------- | Log Channels |-------------------------------------------------------------------------- | | Here you may configure the log channels for your application. Out of | the box, Laravel uses the Monolog PHP logging library. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "single", "daily", "slack", "syslog", | "errorlog", "monolog", | "custom", "stack" | */ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], 'ignore_exceptions' => false, ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => env('LOG_LEVEL', 'critical'), ], 'papertrail' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => SyslogUdpHandler::class, 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), ], ], 'stderr' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => StreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), 'with' => [ 'stream' => 'php://stderr', ], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), ], 'null' => [ 'driver' => 'monolog', 'handler' => NullHandler::class, ], 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/session.php
config/session.php
<?php use Illuminate\Support\Str; return [ /* |-------------------------------------------------------------------------- | Default Session Driver |-------------------------------------------------------------------------- | | This option controls the default session "driver" that will be used on | requests. By default, we will use the lightweight native driver but | you may specify any of the other wonderful drivers provided here. | | Supported: "file", "cookie", "database", "apc", | "memcached", "redis", "dynamodb", "array" | */ 'driver' => env('SESSION_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Session Lifetime |-------------------------------------------------------------------------- | | Here you may specify the number of minutes that you wish the session | to be allowed to remain idle before it expires. If you want them | to immediately expire on the browser closing, set that option. | */ 'lifetime' => env('SESSION_LIFETIME', 120), 'expire_on_close' => false, /* |-------------------------------------------------------------------------- | Session Encryption |-------------------------------------------------------------------------- | | This option allows you to easily specify that all of your session data | should be encrypted before it is stored. All encryption will be run | automatically by Laravel and you can use the Session like normal. | */ 'encrypt' => false, /* |-------------------------------------------------------------------------- | Session File Location |-------------------------------------------------------------------------- | | When using the native session driver, we need a location where session | files may be stored. A default has been set for you but a different | location may be specified. This is only needed for file sessions. | */ 'files' => storage_path('framework/sessions'), /* |-------------------------------------------------------------------------- | Session Database Connection |-------------------------------------------------------------------------- | | When using the "database" or "redis" session drivers, you may specify a | connection that should be used to manage these sessions. This should | correspond to a connection in your database configuration options. | */ 'connection' => env('SESSION_CONNECTION', null), /* |-------------------------------------------------------------------------- | Session Database Table |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ 'table' => 'sessions', /* |-------------------------------------------------------------------------- | Session Cache Store |-------------------------------------------------------------------------- | | While using one of the framework's cache driven session backends you may | list a cache store that should be used for these sessions. This value | must match with one of the application's configured cache "stores". | | Affects: "apc", "dynamodb", "memcached", "redis" | */ 'store' => env('SESSION_STORE', null), /* |-------------------------------------------------------------------------- | Session Sweeping Lottery |-------------------------------------------------------------------------- | | Some session drivers must manually sweep their storage location to get | rid of old sessions from storage. Here are the chances that it will | happen on a given request. By default, the odds are 2 out of 100. | */ 'lottery' => [2, 100], /* |-------------------------------------------------------------------------- | Session Cookie Name |-------------------------------------------------------------------------- | | Here you may change the name of the cookie used to identify a session | instance by ID. The name specified here will get used every time a | new session cookie is created by the framework for every driver. | */ 'cookie' => env( 'SESSION_COOKIE', Str::slug(env('APP_NAME', 'laravel'), '_').'_session' ), /* |-------------------------------------------------------------------------- | Session Cookie Path |-------------------------------------------------------------------------- | | The session cookie path determines the path for which the cookie will | be regarded as available. Typically, this will be the root path of | your application but you are free to change this when necessary. | */ 'path' => '/', /* |-------------------------------------------------------------------------- | Session Cookie Domain |-------------------------------------------------------------------------- | | Here you may change the domain of the cookie used to identify a session | in your application. This will determine which domains the cookie is | available to in your application. A sensible default has been set. | */ 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- | HTTPS Only Cookies |-------------------------------------------------------------------------- | | By setting this option to true, session cookies will only be sent back | to the server if the browser has a HTTPS connection. This will keep | the cookie from being sent to you if it can not be done securely. | */ 'secure' => env('SESSION_SECURE_COOKIE'), /* |-------------------------------------------------------------------------- | HTTP Access Only |-------------------------------------------------------------------------- | | Setting this value to true will prevent JavaScript from accessing the | value of the cookie and the cookie will only be accessible through | the HTTP protocol. You are free to modify this option if needed. | */ 'http_only' => true, /* |-------------------------------------------------------------------------- | Same-Site Cookies |-------------------------------------------------------------------------- | | This option determines how your cookies behave when cross-site requests | take place, and can be used to mitigate CSRF attacks. By default, we | will set this value to "lax" since this is a secure default value. | | Supported: "lax", "strict", "none", null | */ 'same_site' => 'lax', ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/queue.php
config/queue.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Queue Connection Name |-------------------------------------------------------------------------- | | Laravel's queue API supports an assortment of back-ends via a single | API, giving you convenient access to each back-end using the same | syntax for every one. Here you may define a default connection. | */ 'default' => env('QUEUE_CONNECTION', 'sync'), /* |-------------------------------------------------------------------------- | Queue Connections |-------------------------------------------------------------------------- | | Here you may configure the connection information for each server that | is used by your application. A default configuration has been added | for each back-end shipped with Laravel. You are free to add more. | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ 'connections' => [ 'sync' => [ 'driver' => 'sync', ], 'database' => [ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'retry_after' => 90, 'after_commit' => false, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', 'retry_after' => 90, 'block_for' => 0, 'after_commit' => false, ], 'sqs' => [ 'driver' => 'sqs', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'default'), 'suffix' => env('SQS_SUFFIX'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'after_commit' => false, ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, 'block_for' => null, 'after_commit' => false, ], ], /* |-------------------------------------------------------------------------- | Failed Queue Jobs |-------------------------------------------------------------------------- | | These options configure the behavior of failed queue job logging so you | can control which database and table are used to store the jobs that | have failed. You may change them to any database / table you wish. | */ 'failed' => [ 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/cache.php
config/cache.php
<?php use Illuminate\Support\Str; return [ /* |-------------------------------------------------------------------------- | Default Cache Store |-------------------------------------------------------------------------- | | This option controls the default cache connection that gets used while | using this caching library. This connection is used when another is | not explicitly specified when executing a given caching function. | */ 'default' => env('CACHE_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Cache Stores |-------------------------------------------------------------------------- | | Here you may define all of the cache "stores" for your application as | well as their drivers. You may even define multiple stores for the | same cache driver to group types of items stored in your caches. | | Supported drivers: "apc", "array", "database", "file", | "memcached", "redis", "dynamodb", "null" | */ 'stores' => [ 'apc' => [ 'driver' => 'apc', ], 'array' => [ 'driver' => 'array', 'serialize' => false, ], 'database' => [ 'driver' => 'database', 'table' => 'cache', 'connection' => null, 'lock_connection' => null, ], 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], 'options' => [ // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ 'driver' => 'redis', 'connection' => 'cache', 'lock_connection' => 'default', ], 'dynamodb' => [ 'driver' => 'dynamodb', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'endpoint' => env('DYNAMODB_ENDPOINT'), ], ], /* |-------------------------------------------------------------------------- | Cache Key Prefix |-------------------------------------------------------------------------- | | When utilizing a RAM based store such as APC or Memcached, there might | be other applications utilizing the same cache. So, we'll specify a | value to get prefixed to all our keys so we can avoid collisions. | */ 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/hashing.php
config/hashing.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Hash Driver |-------------------------------------------------------------------------- | | This option controls the default hash driver that will be used to hash | passwords for your application. By default, the bcrypt algorithm is | used; however, you remain free to modify this option if you wish. | | Supported: "bcrypt", "argon", "argon2id" | */ 'driver' => 'bcrypt', /* |-------------------------------------------------------------------------- | Bcrypt Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Bcrypt algorithm. This will allow you | to control the amount of time it takes to hash the given password. | */ 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], /* |-------------------------------------------------------------------------- | Argon Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Argon algorithm. These will allow you | to control the amount of time it takes to hash the given password. | */ 'argon' => [ 'memory' => 1024, 'threads' => 2, 'time' => 2, ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/compass.php
config/compass.php
<?php return [ /* |-------------------------------------------------------------------------- | Compass Path |-------------------------------------------------------------------------- | | This is the URI path where Compass will be accessible from. Feel free | to change this path to anything you like. | */ 'path' => env('COMPASS_PATH', 'compass'), /* |-------------------------------------------------------------------------- | Laravel Routes |-------------------------------------------------------------------------- | | This is the routes rules that will be filtered for the requests list. | use "*" as a wildcard to match any characters. note that the following | array list "exclude" can be referenced by the route name or route URI. | "base_uri" is a string value as a comparison for grouping the routes. | */ 'routes' => [ 'domains' => [ '*', ], 'prefixes' => [ '*', ], 'exclude' => [ 'compass.*', 'debugbar.*', '_ignition/*', 'telescope/*', ], 'base_uri' => '*', ], /* |-------------------------------------------------------------------------- | Compass Storage Driver |-------------------------------------------------------------------------- | | This configuration options determines the storage driver that will | be used to store your API calls and routes. In addition, you may set any | custom options as needed by the particular driver you choose. | */ 'driver' => env('COMPASS_DRIVER', 'database'), 'storage' => [ 'database' => [ 'connection' => env('DB_CONNECTION', 'mysql'), ], ], /* |-------------------------------------------------------------------------- | Compass Authenticator |-------------------------------------------------------------------------- | | This options allow you to get all the "credentials" of users that you can | use to perform auth requests through the UI. when "enabled" set to "true" | you should adjust the authentication guard driver for your application to | support "token" or "sanctum". | */ 'authenticator' => [ 'enabled' => false, 'guard' => 'api', 'identifier' => 'email', ], /* |-------------------------------------------------------------------------- | Compass Documenter Provider |-------------------------------------------------------------------------- | | This configuration option determines the documenter provider that will be | used to create a beautiful API documentation. In addition, you may set | any custom options as needed by the particular provider you choose. | */ 'documenter' => 'documentarian', 'provider' => [ 'documentarian' => [ 'output' => 'public/docs', 'example_requests' => [ 'bash', ], ], ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/view.php
config/view.php
<?php return [ /* |-------------------------------------------------------------------------- | View Storage Paths |-------------------------------------------------------------------------- | | Most templating systems load templates from disk. Here you may specify | an array of paths that should be checked for your views. Of course | the usual Laravel view path has already been registered for you. | */ 'paths' => [ resource_path('views'), ], /* |-------------------------------------------------------------------------- | Compiled View Path |-------------------------------------------------------------------------- | | This option determines where all the compiled Blade templates will be | stored for your application. Typically, this is within the storage | directory. However, as usual, you are free to change this value. | */ 'compiled' => env( 'VIEW_COMPILED_PATH', realpath(storage_path('framework/views')) ), ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/database.php
config/database.php
<?php use Illuminate\Support\Str; return [ /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', 'sslmode' => 'prefer', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), ], 'cache' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), ], ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/blade-icons.php
config/blade-icons.php
<?php return [ /* |-------------------------------------------------------------------------- | Icons Sets |-------------------------------------------------------------------------- | | With this config option you can define a couple of | default icon sets. Provide a key name for your icon | set and a combination from the options below. | */ 'sets' => [ // 'default' => [ // // /* // |----------------------------------------------------------------- // | Icons Path // |----------------------------------------------------------------- // | // | Provide the relative path from your app root to your SVG icons // | directory. Icons are loaded recursively so there's no need to // | list every sub-directory. // | // | Relative to the disk root when the disk option is set. // | // */ // // 'path' => 'resources/svg', // // /* // |----------------------------------------------------------------- // | Filesystem Disk // |----------------------------------------------------------------- // | // | Optionally, provide a specific filesystem disk to read // | icons from. When defining a disk, the "path" option // | starts relatively from the disk root. // | // */ // // 'disk' => '', // // /* // |----------------------------------------------------------------- // | Default Prefix // |----------------------------------------------------------------- // | // | This config option allows you to define a default prefix for // | your icons. The dash separator will be applied automatically // | to every icon name. It's required and needs to be unique. // | // */ // // 'prefix' => 'icon', // // /* // |----------------------------------------------------------------- // | Fallback Icon // |----------------------------------------------------------------- // | // | This config option allows you to define a fallback // | icon when an icon in this set cannot be found. // | // */ // // 'fallback' => '', // // /* // |----------------------------------------------------------------- // | Default Set Classes // |----------------------------------------------------------------- // | // | This config option allows you to define some classes which // | will be applied by default to all icons within this set. // | // */ // // 'class' => '', // // /* // |----------------------------------------------------------------- // | Default Set Attributes // |----------------------------------------------------------------- // | // | This config option allows you to define some attributes which // | will be applied by default to all icons within this set. // | // */ // // 'attributes' => [ // // 'width' => 50, // // 'height' => 50, // ], // // ], ], /* |-------------------------------------------------------------------------- | Global Default Classes |-------------------------------------------------------------------------- | | This config option allows you to define some classes which | will be applied by default to all icons. | */ 'class' => '', /* |-------------------------------------------------------------------------- | Global Default Attributes |-------------------------------------------------------------------------- | | This config option allows you to define some attributes which | will be applied by default to all icons. | */ 'attributes' => [ // 'width' => 50, // 'height' => 50, ], /* |-------------------------------------------------------------------------- | Global Fallback Icon |-------------------------------------------------------------------------- | | This config option allows you to define a global fallback | icon when an icon in any set cannot be found. It can | reference any icon from any configured set. | */ 'fallback' => '', /* |-------------------------------------------------------------------------- | Components |-------------------------------------------------------------------------- | | These config options allow you to define some | settings related to Blade Components. | */ 'components' => [ /* |---------------------------------------------------------------------- | Disable Components |---------------------------------------------------------------------- | | This config option allows you to disable Blade components | completely. It's useful to avoid performance problems | when working with large icon libraries. | */ 'disabled' => false, /* |---------------------------------------------------------------------- | Default Icon Component Name |---------------------------------------------------------------------- | | This config option allows you to define the name | for the default Icon class component. | */ 'default' => 'icon', ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false
josuapsianturi/velflix
https://github.com/josuapsianturi/velflix/blob/057684c58e627783f1aa8247fb394d3a8b533d36/config/services.php
config/services.php
<?php return [ /* |-------------------------------------------------------------------------- | Third Party Services |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such | as Mailgun, Postmark, AWS and more. This file provides the de facto | location for this type of information, allowing packages to have | a conventional file to locate the various service credentials. | */ 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], 'ses' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], 'tmdb' => [ 'token' => env('TMDB_TOKEN'), ], 'mailchimp' => [ 'key' => env('MAILCHIMP_KEY'), 'lists' => [ 'subscribers' => env('MAILCHIMP_LIST_SUBSCRIBERS'), ], ], 'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID'), 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 'redirect' => env('GOOGLE_REDIRECT'), ], ];
php
MIT
057684c58e627783f1aa8247fb394d3a8b533d36
2026-01-05T05:17:21.315532Z
false