2017 © Pedro Peláez
 

library accessor

A creator of getter and setter method by using annotations!

image

piano/accessor

A creator of getter and setter method by using annotations!

  • Tuesday, October 31, 2017
  • by diogocavilha
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version, (*1)

Piano Accessor

This package allows us to create getters and setters just by using a few annotations., (*2)

Installing

composer require piano/accessor

Usage example

See the example:, (*3)

This User class:, (*4)

<?php

namespace App;

class User
{
    private $name;
    private $age;
    private $createdAt;

    public function setName($name)
    {
        $this->name = $name;
    }

    public function setAge($age)
    {
        $this->age = (int) $age;
    }

    public function setCreatedAt(\DateTime $createdAt)
    {
        $this->createdAt = $createdAt;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getAge()
    {
        return (int) $this->age;
    }

    public function getCreatedAt()
    {
        return $this->createdAt;
    }
}

Is the same as this User class:, (*5)

<?php

namespace App;

class User
{
    use \Piano\AccessorTrait;

    /**
     * @set
     * @get
     */
    private $name;

    /**
     * @set int
     * @get int
     */
    private $age;

    /**
     * @set \DateTime
     * @get
     */
    private $createdAt;
}

As you can see it's possible to specify the type hint or type cast when defining the @set and it's also possible to specify the type cast when defining the @get. That's optional though., (*6)

As below:, (*7)

Setting Getting
@set int @get int
@set integer @get integer
@set bool @get bool
@set boolean @get boolean
@set float @get float
@set double @get double
@set string @get string
@set array @get array
@set object @get object

For @set any other value will be treated as type hint., (*8)

The Versions

31/10 2017

dev-dev-php-7.1

dev-dev-php-7.1

A creator of getter and setter method by using annotations!

  Sources   Download

The Development Requires

by Diogo Alexsander Cavilha

22/10 2017

dev-docker

dev-docker

A creator of getter and setter method by using annotations!

  Sources   Download

The Development Requires

by Diogo Alexsander Cavilha

31/05 2016

dev-master

9999999-dev

A creator of getter and setter method by using annotations!

  Sources   Download

The Development Requires

by Diogo Alexsander Cavilha

30/05 2016

0.2

0.2.0.0

A creator of getter and setter method by using annotations!

  Sources   Download

The Development Requires

by Diogo Alexsander Cavilha

30/05 2016

0.1

0.1.0.0

A creator of getter and setter method by using annotations!

  Sources   Download

The Development Requires

by Diogo Alexsander Cavilha