{"id":20254807,"url":"https://github.com/chippyash/record-status","last_synced_at":"2025-06-17T19:35:23.506Z","repository":{"id":56952065,"uuid":"115814923","full_name":"chippyash/record-status","owner":"chippyash","description":"Helper library for maintaining record status","archived":false,"fork":false,"pushed_at":"2018-01-09T18:15:43.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-15T11:53:18.521Z","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":"gpl-3.0","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-30T18:25:46.000Z","updated_at":"2017-12-31T09:23:26.000Z","dependencies_parsed_at":"2022-08-21T09:20:17.578Z","dependency_job_id":null,"html_url":"https://github.com/chippyash/record-status","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/chippyash/record-status","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Frecord-status","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Frecord-status/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Frecord-status/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Frecord-status/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chippyash","download_url":"https://codeload.github.com/chippyash/record-status/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2Frecord-status/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260427404,"owners_count":23007502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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:59.224Z","updated_at":"2025-06-17T19:35:18.492Z","avatar_url":"https://github.com/chippyash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chippyash/RStatus\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/record-status.svg)](https://travis-ci.org/chippyash/record-status)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/aa01ddd5d0f3ccd0e137/test_coverage)](https://codeclimate.com/github/chippyash/record-status/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/aa01ddd5d0f3ccd0e137/maintainability)](https://codeclimate.com/github/chippyash/record-status/maintainability)\n\nSee the [Test Contract](https://github.com/chippyash/record-status/blob/master/docs/Test-Contract.md)\n\n## What?\n\nProvides a simple helper capability for managing record or class status\n\n## Why?\n\nWhen dealing with database records, there is often a case for never deleting the record.\nThis can be because you either don't want to lose the data, or you need it in place\nto ensure referential integrity with other data.\n\nThis small library provides the interfaces and traits to add a status functionality\nto any class.\n   \n### Roadmap\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=record-status) for more packages\n\n## How\n\nA record can be in one of three states:\n\n- active. An active record can have be changed to suspended or defunct \n- suspended. A suspended record can be changed to active of defunct.  You should not \nchange the attributes of a suspended reord.\n- defunct. A [defunct](https://www.google.co.uk/search?q=dictionary+defunct\u0026oq=dictionary+defunct\u0026aqs=chrome..69i57j0.6782j1j7\u0026sourceid=chrome\u0026ie=UTF-8)\nrecord or class cannot have its state changed.  This analogous to being deleted, except that the record\ndata remains intact. You must not change the attributes of a defunct record.\n\nWhilst the library provides support to manage the record status, you should also bear\nin mind that you will need to provide additional support to check the status in any\nof your other methods in a class.\n\nIn the docs directory, you'll also find an example trigger that you can use in MySql \nor MariaDb database server to maintain status integrity.\n\n### Coding Basics\n\n#### Record Status Enum class\n\nThe `Chippyash\\RStatus\\RecordStatus` class is provided to provide the three possible\nstates as a an Enum(erator) using the [MyCLabs Enum](https://github.com/myclabs/php-enum) \nlibrary.\n\n\u003cpre\u003e\nuse Chippyash\\RStatus\\RecordStatus;\n\n//create status objects\n$status = RecordStatus::ACTIVE();\n$status = RecordStatus::SUSPENDED();\n$status = RecordStatus::DEFUNCT();\n\n//test if status can be changed\nif ($status-\u003ecanChange()) {\n\t//....\n}\n\u003c/pre\u003e\n\n#### Enabling RecordStatus for your class\n\nHave your class implement the RecordStatusRecordable interface.  Use the \nRecordStatusRecording trait as a convenient implementation of the interface.\n\n\u003cpre\u003e\nuse Chippyash\\RStatus\\RecordStatusRecordable;\nuse Chippyash\\RStatus\\RecordStatusRecording;\n\nclass MyRecord implements RecordStatusRecordable\n{\n\tuse RecordStatusRecording;\n}\n\u003c/pre\u003e\n\nThe RecordStatusRecording trait provides a protected `$recordStatus` propertyand the\nfollowing methods:\n\n\u003cpre\u003e\n/**\n * Return the record status\n *\n * @return RecordStatus\n */\npublic function getStatus();\n\n/**\n * Set the record status\n *\n * @param RecordStatus $status\n *\n * @return $this\n *\n * @throws RecordStatusException\n */\npublic function setStatus(RecordStatus $status);\n\n/**\n * Is record status == active\n *\n * @return bool\n */\npublic function isStatusActive();\n\n/**\n * Is record status == suspended\n *\n * @return bool\n */\npublic function isStatusSuspended();\n\n/**\n * Is record status == defunct\n *\n * @return bool\n */\npublic function isStatusDefunct();\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/record-status). It is\navailable at [Packagist.org](https://packagist.org/packages/chippyash/record-status)\n\n### Installation\n\nInstall [Composer](https://getcomposer.org/)\n\n#### For production\n\n\u003cpre\u003e\n    \"chippyash/record-status\": \"\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/record-status.git\n    cd record-status\n    composer install\n\u003c/pre\u003e\n\nTo run the tests:\n\n\u003cpre\u003e\n    cd record-status\n    vendor/bin/phpunit -c test/phpunit.xml test/\n\u003c/pre\u003e\n\n## License\n\nThis software library is released under the [GNU GPL V3 or later license](http://www.gnu.org/copyleft/gpl.html)\n\nThis software library is Copyright (c) 2017, Ashley Kitson, UK\n\nA commercial license is available for this software library, please contact the author. \nIt is normally free to deserving causes, but gets you around the limitation of the GPL\nlicense, which does not allow unrestricted inclusion of this code in commercial works.\n\n## History\n\nV1.0.0 Original release\n\nV1.0.1 build integration\n\nV1.0.2 typos\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Frecord-status","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchippyash%2Frecord-status","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Frecord-status/lists"}