{"id":21301858,"url":"https://github.com/sergiors/prelude","last_synced_at":"2025-06-23T14:37:39.095Z","repository":{"id":62542485,"uuid":"73966927","full_name":"sergiors/prelude","owner":"sergiors","description":"Functional library for PHP","archived":false,"fork":false,"pushed_at":"2018-03-16T15:01:15.000Z","size":128,"stargazers_count":48,"open_issues_count":1,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-22T02:55:47.229Z","etag":null,"topics":["functional-programming","monad","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergiors.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-16T22:27:13.000Z","updated_at":"2023-10-10T12:49:20.000Z","dependencies_parsed_at":"2022-11-02T16:16:23.591Z","dependency_job_id":null,"html_url":"https://github.com/sergiors/prelude","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sergiors/prelude","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiors%2Fprelude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiors%2Fprelude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiors%2Fprelude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiors%2Fprelude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergiors","download_url":"https://codeload.github.com/sergiors/prelude/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiors%2Fprelude/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261495722,"owners_count":23167369,"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":["functional-programming","monad","php"],"created_at":"2024-11-21T15:53:09.820Z","updated_at":"2025-06-23T14:37:39.064Z","avatar_url":"https://github.com/sergiors.png","language":"PHP","funding_links":[],"categories":["Libraries"],"sub_categories":["[PHP](https://github.com/php/php-src)"],"readme":"Prelude\n-------\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sergiors/prelude/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sergiors/prelude/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/sergiors/prelude/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sergiors/prelude/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/sergiors/prelude/badges/build.png?b=master)](https://scrutinizer-ci.com/g/sergiors/prelude/build-status/master)\n\n\nInstall\n-------\n\n```bash\ncomposer require sergiors/prelude \"dev-master\"\n```\n\nHow to use\n----------\n```php\nuse function Prelude\\cond;\nuse function Prelude\\equals;\nuse function Prelude\\always;\n\n$fn = cond([\n    [equals(0), always('water freezes at 0°C')],\n    [equals(100), always('water boils at 100°C')],\n    [always(true), function ($temp) {\n        return 'nothing special happens at '.$temp.'°C';\n    }]\n]);\n\necho $fn(0); // =\u003e water freezes at 0°C\necho $fn(50); // =\u003e nothing special happens at 50°C\necho $fn(100); // =\u003e water boils at 100°C\n```\n\n```php\nuse function Prelude\\has;\n\n$hasName = has('name');\necho $hasName(['name' =\u003e 'Jimi']); // =\u003e true\necho $hasName([]); // =\u003e false\n```\n\n```php\nuse const Prelude\\id;\nuse const Prelude\\isEmpty;\nuse function Prelude\\ifElse;\nuse function Prelude\\always;\n\n$fn = ifElse(isEmpty)\n    (always(true))\n    (always(false));\necho $fn([]); // =\u003e true\necho $fn(null); // =\u003e true\necho $fn(false); // =\u003e true\necho $fn('James'); // =\u003e false\n```\n\n```php\nuse function Prelude\\head;\n\necho head([1, 2, 3]); // =\u003e 1\n```\n\n```php\nuse function Prelude\\tail;\n\necho tail([1, 2, 3]); // =\u003e [2, 3]\n```\n\nAPI\n---\n\n[**Full API Documentation**](docs/index.md)\n\nThanks\n------\n[Marcelo Camargo](https://github.com/haskellcamargo)\n\nLicense\n-------\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergiors%2Fprelude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergiors%2Fprelude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergiors%2Fprelude/lists"}