2017 © Pedro Peláez
 

library equatable

Provides EquatableInterface for PHP 7+

image

litgroup/equatable

Provides EquatableInterface for PHP 7+

  • Wednesday, September 21, 2016
  • by Sharom
  • Repository
  • 1 Watchers
  • 0 Stars
  • 248 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Equatable for PHP

Provides Equatable for PHP 7+ (inspired by Java)., (*1)

Version Downloads License, (*2)

Installation

composer require litgroup/equatable:^2.0

What is inside

interface Equatable
{
    /**
     * Checks if this object is equal to another one.
     */
    public function equals(Equatable $another): bool;
}

Example of usage

namespace Acme;

use LitGroup\Equatable\Equatable;

class User
{
    private $username;
    private $email;

    public function __construct(string $username, string $email)
    {
        $this->username = $username;
        $this->email = $email;
    }

    public function getUsername(): string
    {
        return $this->username;
    }

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

    /**
     * Example of implementation of Equatable::equals()
     */
    public function equals(Equatable $another): bool
    {
        return 
            $another instanceOf User &&
            $another->getUsername() == $this->getUsername() &&
            $another->getEmail() == $this->getEmail()
        ;
    }
}

LICENSE

See LICENSE file., (*3)

The Versions

21/09 2016

dev-master

9999999-dev

Provides EquatableInterface for PHP 7+

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Roman Shamritskiy

21/09 2016

v2.0.0

2.0.0.0

Provides EquatableInterface for PHP 7+

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Roman Shamritskiy

15/08 2016

v1.0.0

1.0.0.0

Provides EquatableInterface for PHP 7+

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Roman Shamritskiy