Download the PHP package chippyash/identity without Composer

On this page you can find all versions of the php package chippyash/identity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package identity

chippyash/Identity

Quality Assurance

PHP 5.6 PHP 7 Build Status Test Coverage Maintainability

See the Test Contract

What?

Provides a simple helper capability for class Identity management

Why?

This is one of those bits of code you write over and over. Many applications require the classes they use to have some form of Identity. Typically in data driven applications this will equate to the id primary key field. This library provides support for that.

Roadmap

If you want more, either suggest it, or better still, fork it and provide a pull request.

Check out ZF4 Packages for more packages

How

Coding Basics

The code is supplied as an interface and a trait. Simply declare your class as implementing the Identifiable interface and then use the Identifying trait in the class to supply the functionality.

Identities are based on Chippyash\Type\Interfaces\TypeInterface. This allows for strong typing and enforcement of identity rules. For instance, here is an example of a product id that is a fixed length digit string.

use Chippyash\Type\String\DigitType;

/**
 * A unique identifier
 */
class Identifier extends DigitType
{
    /**
     * Length of product id, it will be front padded with zeros to this length
     * or cut to this length
     *
     * @var int
     */
    protected $length = 10;

    /**
     * @return int
     */
    public function getLength()
    {
        return $this->length;
    }

    /**
     * @param mixed $value
     *
     * @return string
     */
    protected function typeOf($value)
    {
        $v = parent::typeOf($value);
        if (strlen($v) > $this->length) {
            return substr($v, -$this->length);
        }

        return str_pad($v, $this->length, '0',STR_PAD_LEFT);
    }
}

Your class can then simpy use it thus:

use Chippyash\Identity\Identifiable;
use Chippyash\Identity\Identifying;

class Product implements Identifiable
{
    use Identifying;

    public function __construct(Identifier $id)
    {
        $this->id = $id;
        //or maybe there is some other way of establishing the identity
    }
}

$product = new Product(new Identifier(53));
$id = $product->id(); // returns Identifier
$vId = $product->vId(); //returns '0000000053'
$vId = $product->id()->get(); //returns '0000000053'

Changing the library

  1. fork it
  2. write the test
  3. amend it
  4. do a pull request

Found a bug you can't figure out?

  1. fork it
  2. write the test
  3. do a pull request

NB. Make sure you rebase to HEAD before your pull request

Or - raise an issue ticket.

Where?

The library is hosted at Github. It is available at Packagist.org

Installation

Install Composer

For production

    "chippyash/identity": ">=1,<2"

For development

Clone this repo, and then run Composer in local repo root to pull in dependencies

    git clone [email protected]:chippyash/identity.git
    cd identity
    composer update

To run the tests:

    cd identity
    vendor/bin/phpunit -c test/phpunit.xml test/

License

This software library is released under the BSD 3 Clause license

This software library is Copyright (c) 2015, Ashley Kitson, UK

History

V1.0.0 Original release

V1.0.1 Updates for build running

V1.0.2 Documentation update

V1.0.3 composer.json fix

V1.0.4 dependency update

V1.1.0 Change of license from GPL V3 to BSD 3 Clause


All versions of identity with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
chippyash/strong-type Version >=5,<6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chippyash/identity contains the following files

Loading the files please wait ....