{"id":20976917,"url":"https://github.com/pixelbrackets/not-empty","last_synced_at":"2025-12-28T21:25:04.736Z","repository":{"id":145819750,"uuid":"285292418","full_name":"pixelbrackets/not-empty","owner":"pixelbrackets","description":"not empty() - Adds methods to determine whether a variable is blank or present - Inspired by Ruby on Rails","archived":false,"fork":false,"pushed_at":"2021-12-06T13:53:06.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T18:29:39.045Z","etag":null,"topics":["blank","empty","php"],"latest_commit_sha":null,"homepage":"https://gitlab.com/pixelbrackets/not-empty/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixelbrackets.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-05T13:13:20.000Z","updated_at":"2021-12-06T13:53:00.000Z","dependencies_parsed_at":"2023-05-26T22:45:23.206Z","dependency_job_id":null,"html_url":"https://github.com/pixelbrackets/not-empty","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelbrackets%2Fnot-empty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelbrackets%2Fnot-empty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelbrackets%2Fnot-empty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelbrackets%2Fnot-empty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelbrackets","download_url":"https://codeload.github.com/pixelbrackets/not-empty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243381191,"owners_count":20281911,"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":["blank","empty","php"],"created_at":"2024-11-19T04:56:19.210Z","updated_at":"2025-12-28T21:24:59.711Z","avatar_url":"https://github.com/pixelbrackets.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# not empty()\n\n[![Version](https://img.shields.io/packagist/v/pixelbrackets/not-empty.svg?style=flat-square)](https://packagist.org/packages/pixelbrackets/not-empty/)\n[![Build Status](https://img.shields.io/gitlab/pipeline/pixelbrackets/not-empty?style=flat-square)](https://gitlab.com/pixelbrackets/not-empty/pipelines)\n[![Made With](https://img.shields.io/badge/made_with-php-blue?style=flat-square)](https://gitlab.com/pixelbrackets/not-empty#requirements)\n[![License](https://img.shields.io/badge/license-gpl--2.0--or--later-blue.svg?style=flat-square)](https://spdx.org/licenses/GPL-2.0-or-later.html)\n\nAdd methods to determine whether a variable is blank or present.\n\nInspired by Ruby on Rails.\n\n## Idea\n\nThis package is a hackathon product. Idea was to port the\n[Ruby on Rails methods](https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html)\n`blank` and `present` to PHP.\n\nPHP has the [empty](https://www.php.net/manual/en/function.empty.php) method,\nbut more often I need to check whether  a variable is not empty.\nThat's why  a `notEmpty` method is available as well.\n\nSee the list below to compare the different behaviour of these methods.\n\n```\n┌─────────────────────────┬─────────┬────────────┬─────────┬───────────┐\n│          VALUE          │ EMPTY() │ NOTEMPTY() │ BLANK() │ PRESENT() │\n├─────────────────────────┼─────────┼────────────┼─────────┼───────────┤\n│ string ''               │ true    │            │ true    │           │\n│ string 'acme'           │         │ true       │         │ true      │\n│ string ' '              │         │ true       │ true    │           │\n│ string '   '            │         │ true       │ true    │           │\n│ string \"\\t\\n\"           │         │ true       │ true    │           │\n│ int 0                   │ true    │            │ true    │           │\n│ float 0.0               │ true    │            │ true    │           │\n│ int 42                  │         │ true       │         │ true      │\n│ float 3.14              │         │ true       │         │ true      │\n│ string '0'              │ true    │            │ true    │           │\n│ string '1337'           │         │ true       │         │ true      │\n│ null                    │ true    │            │ true    │           │\n│ bool true               │         │ true       │         │ true      │\n│ bool false              │ true    │            │ true    │           │\n│ array []                │ true    │            │ true    │           │\n│ array ['acme']          │         │ true       │         │ true      │\n│ object {}               │         │ true       │ true    │           │\n│ object {\"foo\" =\u003e \"bar\"} │         │ true       │         │ true      │\n└─────────────────────────┴─────────┴────────────┴─────────┴───────────┘\n```\n\n## Requirements\n\n- PHP\n\n## Installation\n\nPackagist Entry https://packagist.org/packages/pixelbrackets/not-empty/\n\n## Source\n\nhttps://gitlab.com/pixelbrackets/not-empty/\n\nMirror https://github.com/pixelbrackets/not-empty/\n\n## Usage\n\nSee [tests/demo.php](./tests/demo.php).\n\n```php\nuse Pixelbrackets\\NotEmpty\\Blank;\nuse Pixelbrackets\\NotEmpty\\NotEmpty;\nuse Pixelbrackets\\NotEmpty\\Present;\n\n# Is a string empty? → Use PHPs »empty«\nif (empty('')) { … }\n\n# Is a string not empty? → Use »empty() === false«\nif (empty('acme') === false) { … }\n\n# → …or use »notEmpty« instead\nif (NotEmpty::notEmpty('acme')) { … }\n\n# A strings with whitespaces is blank → use a combination of conditions\nif (is_string('   ') \u0026\u0026 empty(trim('   '))) { … }\n\n# → …or use »blank« instead\nif (Blank::blank('   ')) { … }\n\n# → use »present« to check the opposite of »blank«\nif (Present::present('acme')) { … }\n```\n\n💡 If you want to use the methods as global functions (`blank()` instead of\nthe namespaced `Pixelbrackets\\NotEmpty\\Blank::blank()`) then install the\n»global« branch, using `composer require pixelbrackets/not-empty:dev-global`.\n\n## License\n\nGNU General Public License version 2 or later\n\nThe GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.\n\n## Author\n\nDan Untenzu (\u003cmail@pixelbrackets.de\u003e / [@pixelbrackets](https://pixelbrackets.de))\n\n## Changelog\n\nSee [./CHANGELOG.md](CHANGELOG.md)\n\n## Contribution\n\nThis script is Open Source, so please use, patch, extend or fork it.\n\nThis package is not in active delopment, contributions are welcome though.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelbrackets%2Fnot-empty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelbrackets%2Fnot-empty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelbrackets%2Fnot-empty/lists"}