Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="https://github.com/php-forge/helpers" target="_blank">
<img src="https://avatars.githubusercontent.com/u/103309199?s%25253D400%252526u%25253Dca3561c692f53ed7eb290d3bb226a2828741606f%252526v%25253D4" height="100px">
</a>
<h1 align="center">Collection of Helpers for PHP.</h1>
<h1 align="center">Collection of Helper for PHP.</h1>
<br>
</p>

Expand Down Expand Up @@ -45,7 +45,71 @@ or add

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.
The repository contains a collection of utility functions designed to simplify common programming tasks in PHP.

Whether you're working on web development, data processing, or other projects, these helper functions can save you time
and effort.

## Converts a camelCase formatted string to snake_case

```php
<?php

declare(strict_types=1);

use PHPForge\Helper\WordFormatter;

$word = WordFormatter::camelCaseToSnakeCase('date_birth');
```

## Convert a snake_case formatted string to camelCase

```php
<?php

declare(strict_types=1);

use PHPForge\Helper\WordFormatter;

$word = WordFormatter::snakeCaseToCamelCase('date_birth');
```

## Converts a string to words with capitalized first letters

```php
<?php

declare(strict_types=1);

use PHPForge\Helper\WordFormatter;

$word = WordFormatter::capitalizeToWords('Date Birth');
```

## Generate ramdon pasword

```php
<?php

declare(strict_types=1);

use PHPForge\Helper\Password;

$password = Password::generate(8);
```


## Get all timezones

```php
<?php

declare(strict_types=1);

use PHPForge\Helper\Timezone;

$timezones = Timezone::getAll();
```

## Testing

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "php-forge/helpers",
"name": "php-forge/helper",
"type": "library",
"description": "Collection of Helpers for PHP.",
"description": "Collection of Helper for PHP.",
"keywords": [
"php-forge",
"helpers"
"helper"
],
"license": "mit",
"require": {
Expand All @@ -19,12 +19,12 @@
},
"autoload": {
"psr-4": {
"PHPForge\\Helpers\\": "src"
"PHPForge\\Helper\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"PHPForge\\Helpers\\Tests\\": "tests"
"PHPForge\\Helper\\Tests\\": "tests"
}
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion src/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PHPForge\Helpers;
namespace PHPForge\Helper;

use function array_map;
use function implode;
Expand Down
2 changes: 1 addition & 1 deletion src/TimeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PHPForge\Helpers;
namespace PHPForge\Helper;

use DateTime;
use DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/WordFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PHPForge\Helpers;
namespace PHPForge\Helper;

use function explode;
use function implode;
Expand Down
4 changes: 2 additions & 2 deletions tests/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace PHPForge\Helpers\Tests;
namespace PHPForge\Helper\Tests;

use PHPForge\Helpers\Password;
use PHPForge\Helper\Password;
use PHPUnit\Framework\TestCase;

final class PasswordTest extends TestCase
Expand Down
8 changes: 4 additions & 4 deletions tests/TimeZoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace PHPForge\Helpers\Tests;
namespace PHPForge\Helper\Tests;

use PHPForge\Helpers\TimeZone;
use PHPForge\Helper\TimeZone;
use PHPUnit\Framework\TestCase;

final class TimeZoneTest extends TestCase
Expand Down Expand Up @@ -41,12 +41,12 @@ public function testGetAllReturnsOrderedTimeZones()
$prevOffset = null;

foreach ($timeZones as $timeZone) {
// Verifica que el offset sea mayor o igual al offset anterior
// verify that the offset is greater than or equal to the previous offset
if ($prevOffset !== null) {
$this->assertGreaterThanOrEqual($prevOffset, $timeZone['offset']);
}

// Verifica que el array tenga las claves correctas
// verify that the array contains the expected keys
$this->assertArrayHasKey('timezone', $timeZone);
$this->assertArrayHasKey('name', $timeZone);
$this->assertArrayHasKey('offset', $timeZone);
Expand Down
4 changes: 2 additions & 2 deletions tests/WordFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace PHPForge\Helpers\Tests;
namespace PHPForge\Helper\Tests;

use PHPForge\Helpers\WordFormatter;
use PHPForge\Helper\WordFormatter;
use PHPUnit\Framework\TestCase;

final class WordFormatterTest extends TestCase
Expand Down