2017 © Pedro Peláez
 

library lib-objectdesignpattern-immutable

Functions that are common in immutable objects

image

emeraldinspirations/lib-objectdesignpattern-immutable

Functions that are common in immutable objects

  • Tuesday, August 29, 2017
  • by emeraldinspirations
  • Repository
  • 0 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 38 % Grown

The README.md

emeraldinspirations logo, (*1)

lib-objectdesignpattern-immutable

An object design pattern support class in emeraldinspiration's library., (*2)

Functions that are common in immutable objects, (*3)

Installing / Getting started

This project has no dependencies, so can be cloned directly from the git repo or required with Composer., (*4)

Require with Composer

composer require emeraldinspirations/lib-objectdesignpattern-immutable

Example

<?php

use emeraldinspirations\library\objectDesignPattern\immutable\ImmutableTrait;

class ExampleImmutableObject
{
    use ImmutableTrait;

    protected $Property;

    /**
     * Return value of Property
     *
     * @return \stdclass
     */
    public function getProperty() : \stdclass
    {
        return $this->Property;
    }

    /**
     * Create new instance with new Property value
     *
     * @param \stdclass $Property New value
     *
     * @return self
     */
    public function withProperty(\stdclass $Property) : self {
        return $this->with(__FUNCTION__, $Property);
    }

    /**
     * Clone all specified properties are cloned as necessary
     *
     * @return void
     */
    public function __clone()
    {

        // Create an array of references to properties to clone
        $PropertiesToByCloned = [
            &$this->Property,
        //  ^ - IMPORTANT: Be sure to pass by reference
        ];

        self::cloneArrayRecursively($PropertiesToByCloned);

    }

}

Contributing

If you'd like to contribute, please fork the repository and use a feature branch., (*5)

I am also open to feedback about how well I am being compliant with standards and "best practices." I have written software solo for years, and am trying to learn how to work better with others., (*6)

Licensing

The code in this project is licensed under MIT license., (*7)

The Versions

29/08 2017

dev-master

9999999-dev

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

29/08 2017

2.2.0

2.2.0.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

29/08 2017

2.1.1

2.1.1.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

29/08 2017

2.1.0

2.1.0.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

13/08 2017

2.0.3

2.0.3.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

13/08 2017

2.0.2

2.0.2.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

12/08 2017

2.0.1

2.0.1.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

12/08 2017

2.0.0

2.0.0.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett

12/08 2017

1.0.0

1.0.0.0

Functions that are common in immutable objects

  Sources   Download

MIT

by Matthew "Juniper" Barlett