2017 © Pedro Peláez
 

library laravel-valueobject

Helpers to implement the Value Object pattern in Laravel 5

image

chalcedonyt/laravel-valueobject

Helpers to implement the Value Object pattern in Laravel 5

  • Friday, November 13, 2015
  • by chalcedonyt
  • Repository
  • 1 Watchers
  • 3 Stars
  • 3,145 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Value Object

A simple implementation of the Value Object pattern (http://c2.com/cgi/wiki?ValueObject) with some helpers for Laravel 5., (*1)

Install

Via Composer, (*2)

``` bash $ composer require chalcedonyt/laravel-valueobject:1.*, (*3)


Once composer is finished, add the service provider to the `providers` array in `app/config/app.php`:

Chalcedonyt\ValueObject\Providers\ValueObjectServiceProvider::class, (*4)



## Usage This package adds a helper generator for Value Objects to quickly create them. ``` php php artisan make:valueobject NewValueObject Enter the class or variable name for parameter 0 (Examples: \App\User or $user) [Blank to stop entering parameters] [(no_param)]: > $var1 Enter the class or variable name for parameter 1 (Examples: \App\User or $user) [Blank to stop entering parameters] [(no_param)]: > $var2
<?php
namespace App\ValueObjects;

class NewValueObject extends Chalcedonyt\ValueObject\ValueObject
{
    /**
    * @var
    */
    protected $var1;

    /**
    * @var
    */
    protected $var2;

    /**
    *
    *  @param $var1
    *  @param $var2
    */
    public function __construct( $var1, $var2)
    {
        $this -> var1 = $var1;
        $this -> var2 = $var2;
    }
}

It also introduces a static method create that will return an instance of the ValueObject from an array., (*5)

$args = ['var1' => 1, 'var2' => 2];
$obj = NewValueObject::create($args);
$obj -> __toString(); //"{"var1":1,"var2":2}"

Change log

  • 1.1 You can now create a ValueObject inside a directory by specifying it in the classname, e.g. php artisan make:valueobject MyDir\\MyObject

Please see [CHANGELOG] for more information what has changed recently., (*6)

The Versions

13/11 2015

dev-master

9999999-dev https://github.com/chalcedonyt/laravel-valueobject

Helpers to implement the Value Object pattern in Laravel 5

  Sources   Download

MIT

The Requires

 

by Timothy Teoh

league value object valueobject

13/11 2015

1.01

1.01.0.0 https://github.com/chalcedonyt/laravel-valueobject

Helpers to implement the Value Object pattern in Laravel 5

  Sources   Download

MIT

The Requires

 

by Timothy Teoh

league value object valueobject

08/10 2015

1.0

1.0.0.0 https://github.com/chalcedonyt/laravel-valueobject

Helpers to implement the Value Object pattern in Laravel 5

  Sources   Download

MIT

The Requires

 

by Timothy Teoh

league value object valueobject