{"id":20254774,"url":"https://github.com/chippyash/identity","last_synced_at":"2026-05-11T17:35:56.822Z","repository":{"id":56952064,"uuid":"115491500","full_name":"chippyash/identity","owner":"chippyash","description":"Class Identity helper","archived":false,"fork":false,"pushed_at":"2018-07-04T22:34:29.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T01:17:50.435Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chippyash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-27T06:53:49.000Z","updated_at":"2018-07-04T22:34:31.000Z","dependencies_parsed_at":"2022-08-21T09:20:18.669Z","dependency_job_id":null,"html_url":"https://github.com/chippyash/identity","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/chippyash/identity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Fidentity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Fidentity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Fidentity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Fidentity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chippyash","download_url":"https://codeload.github.com/chippyash/identity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Fidentity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32906414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-11T17:09:15.040Z","status":"ssl_error","status_checked_at":"2026-05-11T17:08:45.420Z","response_time":120,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:34:49.150Z","updated_at":"2026-05-11T17:35:56.807Z","avatar_url":"https://github.com/chippyash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chippyash/Identity\n\n## Quality Assurance\n\n![PHP 5.6](https://img.shields.io/badge/PHP-5.6-blue.svg)\n![PHP 7](https://img.shields.io/badge/PHP-7-blue.svg)\n[![Build Status](https://travis-ci.org/chippyash/identity.svg)](https://travis-ci.org/chippyash/Identity)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/fc8854ae418eacd98d3d/test_coverage)](https://codeclimate.com/github/chippyash/identity/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/fc8854ae418eacd98d3d/maintainability)](https://codeclimate.com/github/chippyash/identity/maintainability)\n\nSee the [Test Contract](https://github.com/chippyash/identity/blob/master/docs/Test-Contract.md)\n\n## What?\n\nProvides a simple helper capability for class Identity management\n\n## Why?\n\nThis is one of those bits of code you write over and over.  Many applications require \nthe classes they use to have some form of Identity.  Typically in data driven applications\nthis will equate to the `id` primary key field.  This library provides support for that.\n   \n### Roadmap\n\n   \nIf you want more, either suggest it, or better still, fork it and provide a pull request.\n\nCheck out [ZF4 Packages](http://zf4.biz/packages?utm_source=github\u0026utm_medium=web\u0026utm_campaign=blinks\u0026utm_content=identity) for more packages\n\n## How\n\n### Coding Basics\n\nThe code is supplied as an interface and a trait.  Simply declare your class as\nimplementing the `Identifiable` interface and then use the `Identifying` trait in the\nclass to supply the functionality.\n\nIdentities are based on Chippyash\\Type\\Interfaces\\TypeInterface.  This allows for\nstrong typing and enforcement of identity rules.  For instance, here is an example\nof a product id that is a fixed length digit string.\n\n\u003cpre\u003e\nuse Chippyash\\Type\\String\\DigitType;\n\n/**\n * A unique identifier\n */\nclass Identifier extends DigitType\n{\n    /**\n     * Length of product id, it will be front padded with zeros to this length\n     * or cut to this length\n     *\n     * @var int\n     */\n    protected $length = 10;\n\n    /**\n     * @return int\n     */\n    public function getLength()\n    {\n        return $this-\u003elength;\n    }\n\n    /**\n     * @param mixed $value\n     *\n     * @return string\n     */\n    protected function typeOf($value)\n    {\n        $v = parent::typeOf($value);\n        if (strlen($v) \u003e $this-\u003elength) {\n            return substr($v, -$this-\u003elength);\n        }\n\n        return str_pad($v, $this-\u003elength, '0',STR_PAD_LEFT);\n    }\n}\n\u003c/pre\u003e \n\nYour class can then simpy use it thus:\n\n\u003cpre\u003e\nuse Chippyash\\Identity\\Identifiable;\nuse Chippyash\\Identity\\Identifying;\n\nclass Product implements Identifiable\n{\n\tuse Identifying;\n\t\n\tpublic function __construct(Identifier $id)\n\t{\n\t\t$this-\u003eid = $id;\n\t\t//or maybe there is some other way of establishing the identity\n\t}\n}\n\n$product = new Product(new Identifier(53));\n$id = $product-\u003eid(); // returns Identifier\n$vId = $product-\u003evId(); //returns '0000000053'\n$vId = $product-\u003eid()-\u003eget(); //returns '0000000053'\n\u003c/pre\u003e\n\n### Changing the library\n\n1.  fork it\n2.  write the test\n3.  amend it\n4.  do a pull request\n\nFound a bug you can't figure out?\n\n1.  fork it\n2.  write the test\n3.  do a pull request\n\nNB. Make sure you rebase to HEAD before your pull request\n\nOr - raise an issue ticket.\n\n## Where?\n\nThe library is hosted at [Github](https://github.com/chippyash/identity). It is\navailable at [Packagist.org](https://packagist.org/packages/chippyash/identity)\n\n### Installation\n\nInstall [Composer](https://getcomposer.org/)\n\n#### For production\n\n\u003cpre\u003e\n    \"chippyash/identity\": \"\u003e=1,\u003c2\"\n\u003c/pre\u003e\n\n#### For development\n\nClone this repo, and then run Composer in local repo root to pull in dependencies\n\n\u003cpre\u003e\n    git clone git@github.com:chippyash/identity.git\n    cd identity\n    composer update\n\u003c/pre\u003e\n\nTo run the tests:\n\n\u003cpre\u003e\n    cd identity\n    vendor/bin/phpunit -c test/phpunit.xml test/\n\u003c/pre\u003e\n\n## License\n\nThis software library is released under the [BSD 3 Clause license](https://opensource.org/licenses/BSD-3-Clause)\n\nThis software library is Copyright (c) 2015, Ashley Kitson, UK\n\n## History\n\nV1.0.0 Original release\n\nV1.0.1 Updates for build running\n\nV1.0.2 Documentation update\n\nV1.0.3 composer.json fix\n\nV1.0.4 dependency update\n\nV1.1.0 Change of license from GPL V3 to BSD 3 Clause","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fidentity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchippyash%2Fidentity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fidentity/lists"}