{"id":21870330,"url":"https://github.com/wordpress-phoenix/random-weighted-conditions","last_synced_at":"2026-05-14T12:31:22.745Z","repository":{"id":91019684,"uuid":"99174742","full_name":"WordPress-Phoenix/random-weighted-conditions","owner":"WordPress-Phoenix","description":"Lightweight PHP class for simplistic weighting of string conditions","archived":false,"fork":false,"pushed_at":"2017-09-13T22:34:16.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T04:36:00.645Z","etag":null,"topics":["math","php","probability","randomizer","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WordPress-Phoenix.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-03T01:01:26.000Z","updated_at":"2017-08-03T02:27:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f72100f-b5f8-4ce3-b31d-d5b506cbda40","html_url":"https://github.com/WordPress-Phoenix/random-weighted-conditions","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/WordPress-Phoenix/random-weighted-conditions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Frandom-weighted-conditions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Frandom-weighted-conditions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Frandom-weighted-conditions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Frandom-weighted-conditions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WordPress-Phoenix","download_url":"https://codeload.github.com/WordPress-Phoenix/random-weighted-conditions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Frandom-weighted-conditions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33024889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["math","php","probability","randomizer","wordpress"],"created_at":"2024-11-28T06:11:05.317Z","updated_at":"2026-05-14T12:31:22.718Z","avatar_url":"https://github.com/WordPress-Phoenix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Random Weighted Conditions\n\nPass a set of conditions and weights, and build a random condition generator.\n\n#### i.e.\n\nWhen serving fruit... \n* Serve `Apples` 50% of the time\n* Serve `Oranges` 10% of the time\n* Serve `Grapes` the rest of the time\n* Serve `Jackfruit` never\n\n# Example\n\n```php\nrequire_once 'class-random-weighted-conditions.php';\n\n$conditions = array(\n\t'apples'    =\u003e 50,\n\t'oranges'   =\u003e 10,\n\t'grapes'    =\u003e null,\n\t`jackfruit` =\u003e 0,\n);\n\n$colors = new \\WPAZ_RWC\\V_1_2\\Random_Weighted_Conditions( $conditions );\n\n// will be `apples` 50%, `oranges` 10% and `grapes` 40%\necho $colors-\u003eget_random_condition();\n```\n\n# How it Works\n### Step 1\nDeveloper provides `array()` of `key =\u003e val` pairs with condition keys and weight values. \n##### Possible Values:\n* 0-100 are treated as percentage weights. 0 completely excludes a condition.\n* All other true-testing `empty()` values are giving _equal distribution of remaining total, following preassigned weights_\n\n### Step 2\nClass validates data and creates an array with 100 string conditions (total can be modified, conditions looped sequentially), based on weights provided.\n\n### Step 3\nClass randomly selects one of strings.\n\n:dancer:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwordpress-phoenix%2Frandom-weighted-conditions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwordpress-phoenix%2Frandom-weighted-conditions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwordpress-phoenix%2Frandom-weighted-conditions/lists"}