2017 © Pedro PelĂĄez
 

library traits

Traits: general usage traits

image

keradus/traits

Traits: general usage traits

  • Thursday, December 11, 2014
  • by keradus
  • Repository
  • 2 Watchers
  • 16 Stars
  • 145 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Traits

Latest Stable Version Latest Unstable Version Build status SensioLabsInsight, (*1)

Traits - general usage traits., (*2)

Traits List

InaccessiblePropertiesProtectorTrait

Trait, that protects accessing inaccessible (unknown) properties to help keeping code clean and safe., (*3)

class Foo
{
    public $baz;
}

$foo = new Foo();
$foo->vaz = 123; // PHP claims that code is OK, even if you misspelled variable name!

class Bar
{
    use InaccessiblePropertiesProtectorTrait;

    public $baz;
}

$bar = new Bar();
$bar->vaz = 123; // now PHP throws \LogicException

InnerClassCacheTrait

Trait, that adds functionality of inner class cache., (*4)

class Foo
{
    use InnerClassCacheTrait;

    public function square($x)
    {
        if (!isset($this->cache[$x])) {
            $this->cache[$x] = $x * $x;
        }

        return $this->cache[$x];
    }
}

InstanceCreationDisallowerTrait

Trait, that disallow to create instance of class. Use for protecting static classes (only static members)., (*5)

class Foo
{
    use InstanceCreationDisallowerTrait;

    public static function createInstance()
    {
        return new static();
    }
}

$foo = new Foo(); // PHP throws fatal error
$foo = Foo::createInstance(); // PHP throws \LogicException

PropertyTrait

Property trait., (*6)

SingletonTrait

StaticPropertyTrait

Property trait in static way., (*7)

The Versions

11/12 2014

dev-master

9999999-dev https://github.com/keradus/Traits

Traits: general usage traits

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

19/11 2014

v1.0

1.0.0.0 https://github.com/keradus/Traits

Traits: general usage traits

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires