2017 © Pedro Peláez
 

library property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

image

alaa-almaliki/property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

  • Thursday, September 7, 2017
  • by alaa-almaliki
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Property Setter Config

A simple class sets object properties by a given array passed in class constructor, (*1)

Installation

Add the following segment to your composer.json file on you project, then run composer install or composer require alaa-almaliki/property-setter-config, (*2)

Example

class MyClass
{
    private $firstName;
    private $lastName;
    private $email;
    private $friends = [];

    public function __construct(array $config = [])
    {
        PropertySetterConfig::setObjectProperties($this, $config);
    }

    public function setFirstName($value)
    {
        $this->firstName = $value;
    }

    public function getFirstName()
    {
        return $this->firstName;
    }

    public function setLastName($value)
    {
        $this->lastName = $value;
        return $this;
    }

    public function getLastName()
    {
        return $this->lastName;
    }

    public function setEmail($value)
    {
        $this->email = $value;
        return $this;
    }

    public function getEmail()
    {
        return $this->email;
    }

    public function setFriends(array $value)
    {
        $this->friends = $value;
        return $this;
    }

    public function getFriends()
    {
        return $this->friends;
    }
}

$obj = new MyClass([
    'first_name' => 'alaa',
    'last_name' => 'almaliki',
    'email'     => 'alaa.almaliki@gmail.com',
    'friends' => [
        'Adam',
        'Melissa',
        'laith',
        'Ahmed'
    ]
]);

Enjoy :), (*3)

The Versions

07/09 2017

dev-master

9999999-dev https://github.com/alaa-almaliki/property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

  Sources   Download

MIT

by Alaa Al-Maliki

property setter method object property setter

07/09 2017

0.1.1

0.1.1.0 https://github.com/alaa-almaliki/property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

  Sources   Download

MIT

by Alaa Al-Maliki

property setter method object property setter

07/09 2017

dev-development

dev-development https://github.com/alaa-almaliki/property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Alaa Al-Maliki

property setter method object property setter

22/08 2017

0.1.0

0.1.0.0 https://github.com/alaa-almaliki/property-setter-config

PHP library can be used to set object properties by a given array passed in the constructor

  Sources   Download

MIT

by Alaa Al-Maliki

property setter method object property setter