2017 © Pedro Peláez
 

library saxulum-accessor

Saxulum Accessor

image

saxulum/saxulum-accessor

Saxulum Accessor

  • Friday, April 20, 2018
  • by dominikzogg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 432 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 19 Versions
  • 0 % Grown

The README.md

saxulum-accessor

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality, (*1)

Features

  • Contains a accessor trait which allows to register accessors
  • Contains a add accessor, which means you don't have to write simple adders anymore
  • Contains a get accessor, which means you don't have to write simple getters anymore
  • Contains a is accessor, which means you don't have to write simple is anymore
  • Contains a remove accessor, which means you don't have to write simple removers anymore
  • Contains a set accessor, which means you don't have to write simple setters anymore

Requirements

  • PHP 5.4+

Installation

Through Composer as saxulum/saxulum-accessor., (*2)

Bootstrap:

``` {.php} AccessorRegistry::registerAccessor(new Add()); AccessorRegistry::registerAccessor(new Get()); AccessorRegistry::registerAccessor(new Is()); AccessorRegistry::registerAccessor(new Remove()); AccessorRegistry::registerAccessor(new Set());, (*3)


## Usage ``` {.php} /** * @method string getName() * @method $this setName(string $name) * @method bool isActive() * @method $this setActive(bool $active) * @method $this addManies(Many $manies) * @method Many[] getManies() * @method $this removeManies(Many $manies) */ class One { use AccessorTrait; /** * @var string */ protected $name; /** * @var bool */ protected $active; /** * @var Many[] */ protected $manies = array(); protected function _initProps() { $this ->_prop((new Prop('name', Hint::STRING)) ->method(Get::PREFIX) ->method(Set::PREFIX) ) ->_prop((new Prop('active', Hint::BOOL)) ->method(Is::PREFIX) ->method(Set::PREFIX) ) ->_prop((new Prop('manies', 'Many[]', true, 'one', Prop::REMOTE_ONE)) ->method(Add::PREFIX) ->method(Get::PREFIX) ->method(Remove::PREFIX) ) ; } } /** * @method string getName() * @method $this setName(string $name) * @method One getOne() * @method $this setOne(One $name) */ class Many { use AccessorTrait; /** * @var string */ protected $name; /** * @var One */ protected $one; protected function _initProps() { $this ->_prop((new Prop('name', Hint::STRING)) ->method(Get::PREFIX) ->method(Set::PREFIX) ) ->_prop((new Prop('one', 'One', true, 'manies', Prop::REMOTE_MANY)) ->method(Add::PREFIX) ->method(Get::PREFIX) ->method(Remove::PREFIX) ) ; } } $one = new One(); $one ->setName('one') ->setActive(true) ; $many = new Many(); $many ->setName('many') ->setOne($one) ; $one->getName(); // return: string 'one' $one->isActive(); // return: bool true $one->getManies(); // return: an array with one instance of 'Many'

PhpDoc generation

Call the method _generatePhpDoc on the object using it, (*4)

{.php} $one = new One(); $one->_generatePhpDoc(), (*5)

Arguments

Pros:

  • less own code to write
  • less owm code to debug
  • scalar type hints
  • handles bidirection relations

Cons:

  • @method phpdoc, needs manually call _generatePhpDoc()
  • slower (no benchmark)
  • more complex to debug
  • method_exists does not work

FAQ

Does it work with doctrine orm/odm (proxy)

Yes it does, thx to __call, (*6)

Does ist work with symfony/property-access (symfony/form)

Yes it does, thx to __get, __set, (*7)

Does it work with twig

Yes it does, thx to the plain property method call wrapper, (*8)

Contributors

  • Dominik Zogg
  • Patrick Landolt

The Versions

20/04 2018

dev-master

9999999-dev

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

12/09 2015

2.0.3

2.0.3.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

30/09 2014

2.0.2

2.0.2.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

30/09 2014

2.0.1

2.0.1.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

30/09 2014

2.0.0

2.0.0.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

29/09 2014

2.0.0-beta5

2.0.0.0-beta5

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

28/09 2014

2.0.0-beta4

2.0.0.0-beta4

Saxulum Accessor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

class accessor saxulum

28/09 2014

2.0.0-beta3

2.0.0.0-beta3

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

28/09 2014

2.0.0-beta2

2.0.0.0-beta2

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

25/09 2014

2.0.0-beta1

2.0.0.0-beta1

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

22/09 2014

1.0.x-dev

1.0.9999999.9999999-dev

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

22/09 2014

1.1.1

1.1.1.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

22/09 2014

1.1.0

1.1.0.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

21/09 2014

1.0.5

1.0.5.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

21/09 2014

1.0.4

1.0.4.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

21/09 2014

1.0.3

1.0.3.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

21/09 2014

1.0.2

1.0.2.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

21/09 2014

1.0.1

1.0.1.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum

20/09 2014

1.0.0

1.0.0.0

Saxulum Accessor

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Dominik Zogg

class accessor saxulum