2017 © Pedro Peláez
 

library yell

A php package that yells when you try to access a property that doesn't exist in a class!

image

zeeshanu/yell

A php package that yells when you try to access a property that doesn't exist in a class!

  • Sunday, September 18, 2016
  • by zeeshanu
  • Repository
  • 1 Watchers
  • 19 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

:loudspeaker: Yell

Scrutinizer Code Quality Code Climate Latest Stable Version License, (*1)

PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects., (*2)

Requirement

PHP >= 5.4.0., (*3)

Installation

You can install the library using the following ways:, (*4)

Using Composer

You can install this through Composer, a dependency manager for PHP. Just run the below command:, (*5)

composer require zeeshanu/yell

For further details you can find the package at Packagist., (*6)

Manual way

  • Copy src to your codebase, perhaps to the vendor directory.
  • Add the Zeeshanu\Yell\Scream class to your autoloader or require the file directly.

Getting Started

I'm going to create take an example to demonstrate the usage., (*7)

For example, you have a Person class like below:, (*8)

class Person
{
    public $name;
    public $age;
}

$person = new Person();

$person->name = 'John Doe';
$person->age = 23;

// Will silently set the property `profession` on `Person` without any issue 
$person->profession = 'Teacher';

Here is how you can make your object strict i.e. not allow any other properties except $name and $age and throw exceptions for any other properties. Just use Zeeshanu\Yell\Scream trait in your class as follows, (*9)

use Zeeshanu\Yell\Scream;

class Person
{
    use Scream;

    public $name;
    public $age;
}

$person = new Person();

$person->name = 'John Doe';
$person->age = 23;

// An exception will be thrown when showing message "Trying to set undefined property $profession in class Person"  
$person->profession = 'Teacher';

Feedback

If you notice that there might be some improvements in code you can create a pull request or report an issue. You can also contact me at ziishaned@gmail.com., (*10)

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

18/09 2016

dev-master

9999999-dev https://github.com/zeeshanu/

A php package that yells when you try to access a property that doesn't exist in a class!

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

22/06 2016

1.0.0

1.0.0.0 https://github.com/zeeshanu/

A php package that yells when you try to access a property that doesn't exist in a class!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires