| Package Data | |
|---|---|
| Maintainer Username: | logcomex |
| Package Create Date: | 2020-04-09 |
| Package Last Update: | 2025-07-01 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-03 15:17:40 |
| Package Statistics | |
|---|---|
| Total Downloads: | 207,006 |
| Monthly Downloads: | 3,103 |
| Daily Downloads: | 98 |
| Total Stars: | 1 |
| Total Watchers: | 4 |
| Total Forks: | 1 |
| Total Open Issues: | 2 |
PHP Utilities for Laravel/Lumen
cd /path/to/your/project
composer require logcomex/php-utils
Have all the contracts (interfaces) used by the php-utils classes and other that you can use in your project.
Have all the exceptions used by the php-utils classes. And others that you can use in your project to segregate your errors types .
You can use for all exceptions in 400 range http code
ApiException(string $token,
string $message,
int $httpCode = Response::HTTP_BAD_REQUEST,
Exception $previous = null)
| Visibility | Function | Return Type | | ---------- | -------------- | ----------- | | public | getHttpCode | int | | public | getToken | string | | public | __toString | string | | public | toArray | array | | public | toJson | string |
This exception means that a situation has been overlooked or incorrectly done by the developer.
BadImplementationException(string $message,
int $httpCode = Response::HTTP_INTERNAL_SERVER_ERROR,
Exception $previous = null)
| Visibility | Function | Return Type | | ---------- | -------------- | ----------- | | public | getHttpCode | int | | public | __toString | string | | public | toArray | array | | public | toJson | string |
This exception serves to point out some security problem in your application.
SecurityException(string $token,
string $message,
int $httpCode = Response::HTTP_FORBIDDEN,
Exception $previous = null)
| Visibility | Function | Return Type | | ---------- | -------------- | ----------- | | public | getHttpCode | int | | public | getToken | string | | public | __toString | string | | public | toArray | array | | public | toJson | string |
They're a pack of traits that can be useful in your code
You can use this functionality to export an array with you class properties
public static function properties(): array
You can use this functionality to attach in your class properties the values passed in the parameter.
Note: To uses this functionality, you need use the PropertiesExporterFunctionality in the class.
public function attachValues(array $values): void
| Exception | Reason | | ---------- | ----------- | | BadImplementationException | When you don't use PropertiesExporterFunctionality |
You can use this functionality to easily get all the properties of class in an array.
Note: To uses this functionality, you need to do two things:
- The class must implement Illuminate\Contracts\Support\Arrayable.
- The class must use PropertiesExporterFunctionality.
public function toArray()
| Exception | Reason | | ---------- | ----------- | | BadImplementationException | When yout don't implement the the Arrayable contract | | BadImplementationException | When you don't use PropertiesExporterFunctionality |
They're a pack of Helpers classes and traits.
It's a trait that provide some utilities to your Enumerators classes.
| Visibility | Function | Return Type | Purpose | | :--- | :--- | :--- |:--- | | public | all | array | Get all the constants of your Enumerator |
use Logcomex\PhpUtils\Helpers\EnumHelper;
class ProductEnum
{
user EnumHelper;
public const EXAMPLE = 'example';
public const EXAMPLE2 = 'example2';
}
$allProducts = ProductEnum::all();
100% at moment.