PHPackages                             miguelcalderonb/meta-statements - 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. miguelcalderonb/meta-statements

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

miguelcalderonb/meta-statements
===============================

Meta-statements is a PHP library that allows execute statements dinamically.

1.0.0(5y ago)13MITPHPPHP ^7.0CI failing

Since Aug 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/miguelcalderonb/meta-statements)[ Packagist](https://packagist.org/packages/miguelcalderonb/meta-statements)[ RSS](/packages/miguelcalderonb-meta-statements/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

miguelcalderonb/meta-statements
===============================

[](#miguelcalderonbmeta-statements)

miguelcalderonb/meta-statements is a PHP library that allows execute statements dinamically from methods.

This allows to modify business rules or behaviours only modifying your data sources.

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

[](#installation)

The preferred method of installation is via \[Composer\]\[\]. Run the following command to install the package and add it as a requirement to your project's

`composer.json`:

```
composer require miguelcalderonb/meta-statements
```

Examples
--------

[](#examples)

### If:

[](#if)

Simple (Static Syntax)

```
use Miguelcalderonb\MTStatements\Conditionals\StmIfExec;

StmIfExec::run(10, '==', 10);
//Output: bool(true)
```

Simple (Object Syntax)

```
use Miguelcalderonb\MTStatements\Conditionals\StmIf;

$ifStatement = new StmIf(10, '==', 10);
$ifStatement->run();
//Output: bool(true)
```

Execute function after statement executed

```
use Miguelcalderonb\MTStatements\Conditionals\StmIfExec;

$customFunction = function ($result ) {
    if ($result) {
        return 'Allowed';
    }

    return 'Rejected';
};

StmIfExec::run(10, '==', 10, $customFunction);
//Output: Allowed

StmIfExec::run(10, '==', 20, $customFunction);
//Output: Rejected
```

Execute function after statement executed (Object Syntax)

```
use Miguelcalderonb\MTStatements\Conditionals\StmIf;

$customFunction = function ($result ) {
    if ($result) {
        return 'Allowed';
    }

    return 'Rejected';
};

$ifStatement = new StmIf(10, '==', 10, $customFunction);
$ifStatement->run(); //Output: Allowed

$ifStatement->second =  20;
$ifStatement->run();
//Output: Rejected
```

### If Complex:

[](#if-complex)

Execute three if at the same time (Object Syntax)

```
use Miguelcalderonb\MTStatements\Conditionals\StmIf;
use Miguelcalderonb\MTStatements\Structs\StatementIfList;
use Miguelcalderonb\MTStatements\Conditionals\StmIfMulti;

$value = 7;

$firstStm = new StmIf($value, '>=', 1, null, '&&');
$secondStm = new StmIf($value, '
