2017 © Pedro Peláez
 

library php-constant

php constant

image

dgame/php-constant

php constant

  • Sunday, January 8, 2017
  • by Dgame
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

php-constant

Scrutinizer Code Quality, (*1)

Dynamic constants at runtime with rust-like lifetime for PHP 7, (*2)

example

<?php
use function Dgame\Constant\get;
use function Dgame\Constant\let;

print '

<

pre>';

function foo()
{
    let('created')->be(time());
    print __METHOD__ . ' -- created: ' . get('created') . PHP_EOL;
//    let('created')->be(time());
}

foo();
foo();

let('created')->be(time());
print 'Global -- created: ' . get('created') . PHP_EOL;

function bar()
{
    let('result')->be(5 * 5);
    print __METHOD__ . ' -- result ' . get('result') . PHP_EOL;
}

bar();

//print 'Global -- created: ' . get('result') . PHP_EOL;

function quatz()
{
    let('result')->be(6 * 6);
    print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;

    foo();
    bar();

    print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;
}

quatz();

let('foo')->be('bar');

print 'Global -- foo: ' . get('foo') . PHP_EOL;

function test()
{
    let('zip_filename')->be('foo.zip');

    print __METHOD__ . ' -- zip_filename: ' . get('zip_filename') . PHP_EOL;

    for ($i = 0; $i < 1; $i++) {
        let('img_filename')->be('bar.png');

        print __METHOD__ . ' -- img_filename: ' . get('img_filename') . PHP_EOL;
    }

    print __METHOD__ . ' -- img_filename: ' . get('img_filename') . PHP_EOL;
    print __METHOD__ . ' -- zip_filename: ' . get('zip_filename') . PHP_EOL;
}

test();

let('fac')->be(function(int $in) {
    $out = 1;

    // Only if $in is >= 2
    for ($i = 2; $i <= $in; $i++) {
        $out *= $i;
    }

    return $out;
});

print 'Global -- fac: ' . get('fac')(6) . PHP_EOL;

The Versions

08/01 2017

dev-master

9999999-dev https://github.com/php-constant

php constant

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

immutable constant

14/09 2016

v0.3.0

0.3.0.0 https://github.com/php-constant

php constant

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

immutable constant

10/09 2016

v0.2.0

0.2.0.0 https://github.com/php-constant

php constant

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

immutable constant

09/06 2016

v0.1.1

0.1.1.0 https://github.com/php-constant

php constant

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

09/06 2016

v0.1.0

0.1.0.0 https://github.com/php-constant

php constant

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires