Skip to content

Commit

Permalink
Reorganize namespace and file autoloader (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfirdaus authored May 27, 2024
1 parent c986051 commit 0308040
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 35 deletions.
22 changes: 0 additions & 22 deletions app/Inflector/Inflector.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

declare(strict_types=1);

namespace Syntatis\Utils\CaseConverter;
namespace Syntatis\Utils\Str\CaseConverter;

use Jawira\CaseConverter\CaseConverter as CaseConverterFactory;

class CaseConverter
/** @internal */
final class CaseConverter
{
private static ?CaseConverterFactory $instance = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Syntatis\Utils;

use Syntatis\Utils\CaseConverter\CaseConverter;
use Syntatis\Utils\Str\CaseConverter\CaseConverter;

/**
* Convert a string to "camelCase" format.
Expand Down
23 changes: 23 additions & 0 deletions app/Str/Inflector/Inflector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Syntatis\Utils\Str\Inflector;

use Doctrine\Inflector\Inflector as DoctrineInflector;
use Doctrine\Inflector\InflectorFactory;

/** @internal */
final class Inflector
{
private static ?DoctrineInflector $instance = null;

public static function instance(): DoctrineInflector
{
if (self::$instance === null) {
self::$instance = InflectorFactory::create()->build();
}

return self::$instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Syntatis\Utils;

use Syntatis\Utils\Inflector\Inflector;
use Syntatis\Utils\Str\Inflector\Inflector;

/**
* Convert a string (word) to its singular form.
Expand Down
3 changes: 2 additions & 1 deletion app/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface;

class Validator
/** @internal */
final class Validator
{
private static ?ValidatorInterface $instance = null;

Expand Down
7 changes: 7 additions & 0 deletions app/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

require_once __DIR__ . '/Str/CaseConverter/functions.php';
require_once __DIR__ . '/Str/Inflector/functions.php';
require_once __DIR__ . '/Validator/functions.php';
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
comment:
layout: "condensed_header, condensed_files, condensed_footer"
hide_project_coverage: true
ignore:
- "app/functions.php"
8 changes: 2 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@
"prefer-stable": true,
"autoload": {
"files": [
"app/CaseConverter/functions.php",
"app/Inflector/functions.php",
"app/Validator/functions.php"
"app/functions.php"
],
"psr-4": {
"Syntatis\\Utils\\": "app"
}
},
"autoload-dev": {
"files": [
"app/CaseConverter/functions.php",
"app/Inflector/functions.php",
"app/Validator/functions.php"
"app/functions.php"
],
"psr-4": {
"Syntatis\\Utils\\Tests\\": "tests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Syntatis\Utils\Tests;
namespace Syntatis\Utils\Tests\Str;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\TestDox;
Expand Down
2 changes: 1 addition & 1 deletion tests/InflectorTest.php → tests/Str/InflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Syntatis\Utils\Tests;
namespace Syntatis\Utils\Tests\Str;

use PHPUnit\Framework\TestCase;

Expand Down

0 comments on commit 0308040

Please sign in to comment.