{"id":20254735,"url":"https://github.com/chippyash/logical-matrix","last_synced_at":"2025-07-26T10:04:32.337Z","repository":{"id":18591252,"uuid":"21795666","full_name":"chippyash/Logical-matrix","owner":"chippyash","description":"Logical matrix operations for PHP","archived":false,"fork":false,"pushed_at":"2018-07-04T22:43:50.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T00:04:33.876Z","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":"2014-07-13T17:10:58.000Z","updated_at":"2020-04-03T09:42:45.000Z","dependencies_parsed_at":"2022-09-14T13:12:33.602Z","dependency_job_id":null,"html_url":"https://github.com/chippyash/Logical-matrix","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FLogical-matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FLogical-matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FLogical-matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FLogical-matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chippyash","download_url":"https://codeload.github.com/chippyash/Logical-matrix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317705,"owners_count":21083528,"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:39.270Z","updated_at":"2025-04-11T00:04:42.263Z","avatar_url":"https://github.com/chippyash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chippyash/logical-matrix\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/Logical-matrix.svg?branch=master)](https://travis-ci.org/chippyash/Logical-matrix)\n[![Test Coverage](https://codeclimate.com/github/chippyash/Logical-matrix/badges/coverage.svg)](https://codeclimate.com/github/chippyash/Logical-matrix/coverage)\n[![Code Climate](https://codeclimate.com/github/chippyash/Logical-matrix/badges/gpa.svg)](https://codeclimate.com/github/chippyash/Logical-matrix)\n\nSee the [Test Contract](https://github.com/chippyash/Logical-matrix/blob/master/docs/Test-Contract.md)\n\nPlease note that developer support for PHP5.4 \u0026 5.5 was withdrawn at version 3.0.0 of this library.\nIf you need support for PHP 5.4 or 5.5, please use a version `\u003e=2,\u003c3`\n\n## What?\n\nThis library aims to provide logic matrix functionality and builds on the\nchippyash/Matrix matrix data structure library:\n\n*  Everything has a test case\n*  It's PHP 5.4+\n\n## When\n\nThe current library covers basic logical matrix manipulation.\n\nIf you want more, either suggest it, or better still, fork it and provide a pull request.\n\nCheck out [chippyash/Matrix](https://github.com/chippyash/Matrix) for Matrix data type support.\n\nCheck out [chippyash/Math-Matrix](https://github.com/chippyash/Math-Matrix) for mathematical matrix operations\n\nCheck out [ZF4 Packages](http://zf4.biz/packages?utm_source=github\u0026utm_medium=web\u0026utm_campaign=blinks\u0026utm_content=logicmatrix) for more packages\n\n### Operations supported\n\n*  AndMatrix - return the result of two matrices ANDed\n*  AndOperand - return matrix ANDed with a boolean operand\n*  Not - return !matrix\n*  OrMatrix - return the result of two matrices ORed\n*  OrOperand - return matrix ORed with a boolean operand\n*  XorMatrix - return the result of two matrices XORed\n*  XorOperand - return matrix XORed with a boolean operand\n\nThe library is released under the [GNU GPL V3 or later license](http://www.gnu.org/copyleft/gpl.html)\n\n## How\n\nPlease see the [chippyash/Matrix](https://github.com/chippyash/Matrix) for underlying\nfunctionality.  Anything you can do with a Matrix, you can do with a LogicalMatrix.\n\n### Coding Basics\n\nA LogicalMatrix is a matrix for which all entries are a boolean value; true or false\n\nA shortcut for a single item matrix is to supply a single array\n\n\u003cpre\u003e\n    use chippyash\\Logic\\Matrix\\LogicalMatrix;\n\n    $mA = new LogicalMatrix([]);  //empty matrix\n    $mA = new LogicalMatrix([[]]);  //empty matrix\n    $mA = new LogicalMatrix([true]);  //single item matrix\n    $mA = new LogicalMatrix([2, false]);  //1x2 matrix\n    $mA = new LogicalMatrix([2, false],[true, 'foo']);  //2x2 matrix\n\u003c/pre\u003e\n\nN.B.  A matrix construction values are converted to their boolean equivalent, so\n'' = false, 'foo' = true, 1 = true, 0 = false etc, according to normal PHP casting\nrules for boolean.\n\nAs with any TDD application, the tests tell you everything you need to know about\nthe SUT.  Read them!  However for the short of temper amongst us, the salient\npoints are:\n\nA Logical Matrix type is supplied\n\n*  LogicalMatrix(array $source, bool $normalizeDefault = false)\n\n#### Logical Matrices have additional attributes over and above a Matrix\n\n*  Attributes always return a boolean.\n*  You can use the is() method of a Matrix to test for an attribute\n*  Attributes implement the chippyash\\Matrix\\Interfaces\\AttributeInterface\n\n\u003cpre\u003e\n    //assuming $mA is a LogicalMatrix - this will return true\n    if ($mA-\u003eis('Logical')) {}\n    //is the same as, which can also be used on ordinary matrices\n    $attr = new Logic\\Matrix\\Attribute\\IsLogical();\n    if ($attr($mA) {}\n\u003c/pre\u003e\n\n#### Logical Matrices have operations\n\n*  Operations always returns a Logical Matrix\n*  The original matrix is untouched\n*  You can use the magic __invoke functionality\n*  Operations implement the chippyash\\Logical\\Matrix\\Interfaces\\OperationInterface\n\n\u003cpre\u003e\n    $mC = $mA(\"AndMatrix\", $mB);\n    //same as :\n    $op = new Logic\\Matrix\\Operation\\AndMatrix;\n    $mC = $op($mA, $mB);\n\u003c/pre\u003e\n\nThe following operations are supplied:\n\n- AndMatrix - AND two matrices\n- AndOperand - AND matrix with boolean\n- Not - NOT a matrix\n- OrMatrix - OR two matrices\n- OrOperand - OR matrix with boolean\n- XorMatrix - XOR two matrices\n- XorOperand - XOR matrix with boolean\n\n#### The magic invoke methods allow you to write in a functional way\n\n\u003cpre\u003e\n        $fAnd = new AndMatrix();\n        $fOr = new OrOperand();\n        //($mA \u0026\u0026 $mB) || true\n        return $fOr($fAnd($mA, $mB), true);\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\n## Where?\n\nThe library is hosted at [Github](https://github.com/chippyash/Logical-matrix). It is\navailable at [Packagist.org](https://packagist.org/packages/chippyash/logical-matrix)\n\n### Installation\n\nInstall [Composer](https://getcomposer.org/)\n\n#### For production\n\nadd\n\n\u003cpre\u003e\n    \"chippyash/logical-matrix\": \"~2.0\"\n\u003c/pre\u003e\n\nto your composer.json \"requires\" section\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/Logical-matrix.git LogicMatrix\n    cd LogicMatrix\n    composer update\n\u003c/pre\u003e\n\nTo run the tests:\n\n\u003cpre\u003e\n    cd LogicMatrix\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) 2014-2018, Ashley Kitson, UK\n\n## History\n\nV0...  pre releases\n\nV1.0.0 Original release\n\nV1.0.5 Update for underlying library dependency\n\nV1.0.6 Update phpunit version\n\nV2.0.0 BC Break: change namespace from chippyash to Chippyash\n\nV2.0.1 Add link to packages\n\nV2.0.2 Verify PHP7 compatibility\n\nV2.0.3 Update build script\n\nV3.0.0 BC Break. Withdraw support for old PHP versions\n\nV3.1.0 Change of license from GPL V3 to BSD 3 Clause","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Flogical-matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchippyash%2Flogical-matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Flogical-matrix/lists"}