PHPackages                             exylon/fuse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. exylon/fuse

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

exylon/fuse
===========

Collection of Laravel utilities

0220PHP

Since Nov 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/exylon/laravel-fuse)[ Packagist](https://packagist.org/packages/exylon/fuse)[ RSS](/packages/exylon-fuse/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Fuse
====

[](#fuse)

> This is still in active development. Use with certain pre-caution.

> Requires an intermediate knowledge in Laravel and Software Design Patterns

Collection of Laravel utilities

Installation
------------

[](#installation)

```
composer require exylon/fuse:dev-master
```

Artisan Helpers
---------------

[](#artisan-helpers)

#### `php artisan make:subscriber`

[](#php-artisan-makesubscriber)

Creates a new Subscriber class based on [Laravel Subscriber](https://laravel.com/docs/master/events#event-subscribers)

ParametersDescriptionExample`name`Subscriber class name`AuthEventsSubscriber`OptionsDescriptionExample`--event=`The event class/es being listened for.`Illuminate\\Auth\\Events\\Login`Basic Usage:

```
$ php artisan make:subscriber AuthEventsSubscriber --event="Illuminate\\Auth\\Events\\Login" --event="Illuminate\\Auth\\Events\\Logout"
```

#### `php artisan make:repository`

[](#php-artisan-makerepository)

Creates a new [repository](https://martinfowler.com/eaaCatalog/repository.html) class

ParametersDescriptionExample`model`Target model`User`OptionsDescriptionExample`--no-interface`By default, a repository interface and an Eloquent implementation will be created. If you wish to use Eloquent implementation solely, add this as optionBasic Usage:

```
$ php artisan make:repository User --no-interface
```

#### `php artisan make:service`

[](#php-artisan-makeservice)

Creates a new [service](https://martinfowler.com/eaaCatalog/serviceLayer.html) class.

ParametersDescriptionExample`name`Service class name`UserService`OptionsDescriptionExample`--repository=`Provides the repository to be used by the service`UserRepository``--crud`Adds create, update and delete methodsBasic Usage:

```
$ php artisan make:service UserService -r=UserRepository --crud
```

Helper Functions
----------------

[](#helper-functions)

#### `str_replace_assoc(array $pairs, $subject)`

[](#str_replace_assocarray-pairs-subject)

String replace using key-value pair (assoc array).

#### `validate(array $data, array $rules)`

[](#validatearray-data-array-rules)

Shorthand for `\Validator::validate($data, $rules)`

#### `str_random_hex($length)`

[](#str_random_hexlength)

Generates a random hexadecimal string with fixed length.

Example: `$var = str_random_hex(10) //ffeb09ed56`

#### `str_random_int($length, $min = 0, $pad = '0')`

[](#str_random_intlength-min--0-pad--0)

Generates a random numeric string. If the generated numeric string is shorter than the `$length`, it will be padded by the `$pad`.

Example: `$var = str_random_int(5) //01467`

#### `proper_case($str,$delimiters = '_')`

[](#proper_casestrdelimiters--_)

Converts a string to proper cased string

Examples:

```
$var = proper_case('lorem_ipsum_dolor') // Lorem Ipsum Dolor
$var = proper_case('lorem_ipsum-dolor') // Lorem Ipsum-Dolor
$var = proper_case('lorem_ipsum-dolor',['_','-']) // Lorem Ipsum Dolor
```

Helper Traits and Classes
-------------------------

[](#helper-traits-and-classes)

### `\Exylon\Fuse\Support\Attributes`

[](#exylonfusesupportattributes)

Associative array on steroids. Converts regular associative array to standard objects

```
$arr = new Attributes([
              'red'    => 'apple',
              'orange' => 'orange',
              'yellow' => [
                  'mangoes' => 'foo',
                  'pear'    => 'bar'
              ]
          ]);

echo $arr['red']; // "apple"
echo $arr->red; // "apple"

echo $arr['yellow']['mangoes']; // "foo"
echo $arr->yellow->mangoes; // "foo"
```

Working with aliases. *Note: Currently, aliases supports the first level keys only*

```
$arr = new Attributes([
              'red'    => 'apple',
              'orange' => 'orange',
              'yellow' => [
                  'mangoes' => 'foo',
                  'pear'    => 'bar'
              ]
          ],[ // 'pula' as an alias for 'red'
              'pula'   => 'red'
          ]);

echo $arr['red']; // "apple"
echo $arr->red; // "apple"

echo $arr['pula']; // "apple"
echo $arr->pula; // "apple"
```

#### `Attributes::toJson($options=0)`

[](#attributestojsonoptions0)

Converts the attributes to json

### `\Exylon\Fuse\Support\Eloquent\CascadeDelete`

[](#exylonfusesupporteloquentcascadedelete)

Enables cascade delete on the PHP side. Useful for polymorphic relationships.

```
/*
 * 'Team' model can also have payment methods. That's the reason
 * PaymentMethod is poloymorphic.
 */
class Customer extends Model {
    use CascadeDelete;

    protected $cascade = [
        'paymentMethods'
    ];

    public function paymentMethods(){
        return $this->morphMany(PaymentMethod::class,'owner');
    }
}
...
$customer->delete(); // this will delete all related payment methods
```

Helper Macros
-------------

[](#helper-macros)

#### `Request::location()`

[](#requestlocation)

Using [`torann/geoip`](http://lyften.com/projects/laravel-geoip/doc/),

```
\Exylon\Fuse\Support\Attributes {
  #attributes: array [
    "ip" => "127.0.0.0"
    "iso_code" => "PH"
    "country" => "Philippines"
    "city" => "Paranaque"
    "state" => "MNL"
    "state_name" => "Manila"
    "postal_code" => "06510"
    "lat" => 14.471016
    "lon" => 121.01476
    "timezone" => "Asia/Manila"
    "continent" => "NA"
    "currency" => "USD"
    "default" => true
    "cached" => false
  ]
  #aliases: array [
    "country_code" => "iso_code"
    "latitude" => "lat"
    "longitude" => "lon"
    "zip_code" => "postal_code"
  ]
}
```

#### `Request::agent()`

[](#requestagent)

Using [`jenssegers/agent`](https://github.com/jenssegers/agent)

```
\Exylon\Fuse\Support\Attributes {
  #attributes: array [
    "agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
    "is_mobile" => false
    "is_phone" => false
    "is_tablet" => false
    "device" => "Macintosh"
    "is_desktop" => true
    "platform" => "OS X"
    "is_robot" => false
    "robot" => false
    "browser" => "Chrome"
    "languages" => array:2 [▶]
  ]
}
```

#### `Builder::forceMake($attributes)`

[](#builderforcemakeattributes)

Coincides with Eloquent Models' `forceCreate`, this method creates an instance of the model without persisting and avoiding MassAssignmentException. *NOTE: Make sure that you pre-validated the attributes.*

```
$user = User::forceMake(['name'=>'John Doe']);
```

`FuseSanitizer` Facade
----------------------

[](#fusesanitizer-facade)

Cleans up your data based on rules.

#### Inline Rules

[](#inline-rules)

```
$data = [
    'email' =>  '    EXAMPLE@EXAMPLE.COM    '
];
$data = FuseSanitizer::sanitize($data,[
          '*' =>  'trim::string', // Wildcard
          'email' =>  'strtolower' // Applicable only fields named 'email'
      ]); // ['email' => 'example@example.com']
```

The 'email' rule will be only applicable to fields with name 'email'. Int this case, `strtolower` will be called if there exists an 'email' field from the data.

The `*` signifies a wildcard which makes it applicable to "any" field, but take note that the included rule is `trim::string`. The rule is divided into three parts - *function*, *parameters*, *data type* -, which is separated by colon ('`:`'); *parameters* are further divided by comma ('`,`'). By default, data type will be assumed as string. In our case, for the function `trim` we don't need any parameters but we need to supply a data type to make it applicable only to `string`-typed data. Available data types are `string`,`array`, `int`, `float`, and `double`.

#### Inline Rules with Global Rules

[](#inline-rules-with-global-rules)

Sample:

```
FuseSanitizer::setGlobalRules([
    'email' =>  'trim'
]);
$data = [
    'email' =>  '    EXAMPLE@EXAMPLE.COM    '
];
$data = FuseSanitizer::sanitize($data,[
          'email' =>  'strtolower'
      ]); // ['email' => 'example@example.com']
```

The rules are prioritized in this manner:

1. Global Wildcard
2. Global Rule
3. Inline Wildcard
4. Inline Rule

If you set the global rules, the inline rules are optional. Sample:

```
FuseSanitizer::setGlobalRules([
    'email' =>  ['trim','strtolower']
]);
$data = [
    'email' =>  '    EXAMPLE@EXAMPLE.COM    '
];
$data = FuseSanitizer::sanitize($data); // ['email' => 'example@example.com']
```

#### Sanitizing a single value

[](#sanitizing-a-single-value)

Sample:

```
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ',['trim','strtolower']); // 'example@example.com'
```

#### Rule Set Formats

[](#rule-set-formats)

##### Using pipe (`|`) separated rules

[](#using-pipe--separated-rules)

```
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ','trim|strtolower'); // 'example@example.com'
```

##### Using array

[](#using-array)

```
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ', ['trim','strtolower']); // 'example@example.com'
```

##### Using callbacks

[](#using-callbacks)

```
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ', ['trim',function($value){
    return strtolower($value);
}]); // 'example@example.com'
```

##### Using class/method pair

[](#using-classmethod-pair)

```
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ', ['trim','App\\Support\\SanitizerHelper@toLower']); // 'example@example.com'
```

#### Extending callbacks via `FuseSanitizer::register`

[](#extending-callbacks-via-fusesanitizerregister)

```
FuseSanitizer::register('tolower',function($value){
  return strtolower($value);
});
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ', ['trim','tolower']); // 'example@example.com'
```

```
FuseSanitizer::register('tolower','App\\Support\\SanitizerHelper@toLower');
$email = FuseSanitizer::sanitizeValue('    EXAMPLE@EXAMPLE.COM    ', ['trim','tolower']); // 'example@example.com'
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/da7ddc40449716fd2329272f87412984b682cabb3de915e99f33b8475f6fe818?d=identicon)[edmandiesamonte](/maintainers/edmandiesamonte)

---

Top Contributors

[![edmandiesamonte](https://avatars.githubusercontent.com/u/11081512?v=4)](https://github.com/edmandiesamonte "edmandiesamonte (103 commits)")

### Embed Badge

![Health badge](/badges/exylon-fuse/health.svg)

```
[![Health](https://phpackages.com/badges/exylon-fuse/health.svg)](https://phpackages.com/packages/exylon-fuse)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
