https://github.com/elusivecodes/fyremacro
FyreMacro is a free, open-source string utility library for PHP.
https://github.com/elusivecodes/fyremacro
macro php utility
Last synced: 5 months ago
JSON representation
FyreMacro is a free, open-source string utility library for PHP.
- Host: GitHub
- URL: https://github.com/elusivecodes/fyremacro
- Owner: elusivecodes
- License: mit
- Created: 2025-07-27T11:28:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-27T11:31:51.000Z (11 months ago)
- Last Synced: 2025-08-29T13:55:06.710Z (10 months ago)
- Topics: macro, php, utility
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FyreMacro
**FyreMacro** is a free, open-source macro utility library for *PHP*.
## Table Of Contents
- [Installation](#installation)
- [Macros](#macros)
- [Calling Macros](#calling-macros)
- [Static Macros](#static-macros)
- [Calling Static Macros](#calling-static-macros)
## Installation
**Using Composer**
```
composer require fyre/macro
```
## Macros
You can attach `Fyre\Utility\Traits\MacroTrait` to any class.
```php
use Fyre\Utility\Traits\MacroTrait;
// in any class
class MyClass {
use MacroTrait;
}
```
**Clear Macros**
Clear all macros.
```php
MyClass::clearMacros();
```
**Has Macro**
Determine whether a macro is registered.
- `$name` is a string representing the name of the macro.
```php
$hasMacro = MyClass::hasMacro($name);
```
**Macro**
Register a macro.
- `$name` is a string representing the name of the macro.
- `$callback` is the macro callback.
```php
MyClass::macro($name, $callback);
```
### Calling Macros
```php
MyClass::macro('myMethod', function(): bool {
return true;
});
new MyClass()->myMethod(); // true
```
## Static Macros
You can attach `Fyre\Utility\Traits\StaticMacroTrait` to any class.
```php
use Fyre\Utility\Traits\StaticMacroTrait;
// in any class
class MyClass {
use StaticMacroTrait;
}
```
**Clear Static Macros**
Clear all static macros.
```php
MyClass::clearStaticMacros();
```
**Has Static Macro**
Determine whether a static macro is registered.
- `$name` is a string representing the name of the macro.
```php
$hasStaticMacro = MyClass::hasStaticMacro($name);
```
**Static Macro**
Register a static macro.
- `$name` is a string representing the name of the macro.
- `$callback` is the macro callback.
```php
MyClass::staticMacro($name, $callback);
```
### Calling Static Macros
```php
MyClass::staticMacro('myMethod', function(): bool {
return true;
});
MyClass::myMethod(); // true
```