{"id":15589609,"url":"https://github.com/sokil/php-list","last_synced_at":"2026-03-01T15:03:51.353Z","repository":{"id":23671365,"uuid":"27042544","full_name":"sokil/php-list","owner":"sokil","description":"Priority list","archived":false,"fork":false,"pushed_at":"2021-02-16T21:41:17.000Z","size":30,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-05T03:19:42.682Z","etag":null,"topics":["php","priority-list","weight-list"],"latest_commit_sha":null,"homepage":null,"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/sokil.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":"2014-11-23T18:29:29.000Z","updated_at":"2021-02-16T21:41:19.000Z","dependencies_parsed_at":"2022-08-24T03:41:01.443Z","dependency_job_id":null,"html_url":"https://github.com/sokil/php-list","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sokil/php-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sokil","download_url":"https://codeload.github.com/sokil/php-list/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-list/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29973180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T14:44:57.896Z","status":"ssl_error","status_checked_at":"2026-03-01T14:43:27.662Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["php","priority-list","weight-list"],"created_at":"2024-10-02T23:03:17.214Z","updated_at":"2026-03-01T15:03:51.319Z","avatar_url":"https://github.com/sokil.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Lists\n=====\n\n[![Build Status](https://travis-ci.org/sokil/php-list.png?branch=master\u00261)](https://travis-ci.org/sokil/php-list)\n[![Latest Stable Version](https://poser.pugx.org/sokil/php-list/v/stable.png)](https://packagist.org/packages/sokil/php-list)\n[![Coverage Status](https://coveralls.io/repos/sokil/php-list/badge.png)](https://coveralls.io/r/sokil/php-list)\n[![Total Downloads](http://img.shields.io/packagist/dt/sokil/php-list.svg?1)](https://packagist.org/packages/sokil/php-list)\n[![Daily Downloads](https://poser.pugx.org/sokil/php-list/d/daily)](https://packagist.org/packages/sokil/php-list/stats)\n\n* [Installation](#installation)\n* [Priority List](#priority-list)\n* [Weight List](#weight-list)\n\n## Installation\n\nYou can install library through Composer:\n\n```javascript\n{\n    \"require\": {\n        \"sokil/php-list\": \"dev-master\"\n    }\n}\n```\n\n## Priority Map\n\nPriority map allows you to specify priority of items and \niterate through this list in order to priority.\n\nAdd elements to list with priority:\n\n```php\n\u003c?php\n\n$list = new \\Sokil\\DataType\\PriorityMap();\n$list-\u003eset('key1', 'value1', 10);\n$list-\u003eset('key2', 'value2', 100);\n```\n\nGet elements according to priority:\n\n```php\n\u003c?php\nforeach($list as $key =\u003e $value) {\n    echo $key . ' - ' . $value;\n}\n\n// this will print\n//   key2 - value2\n//   key1 - value1\n```\n\nGet element by key:\n\n```php\n\u003c?php\n\n$list = new \\Sokil\\DataType\\PriorityMap();\n$list-\u003eset('key1', 'value1', 10);\n$list-\u003eget('key1');\n```\n    \n## Weight List\n\nWeight list allows you to specify values and relative weights, and randomly\nget value according to it's weight.\n\nImagine that we have three database servers with ip addresses: 10.0.0.1, 10.0.0.2 and 10.0.0.3.\nWe want to balance connections between nodes with weights 60%, 30% and 10%. So \nmost connections goes to server 10.0.0.1, than to 10.0.0.2 and than to 10.0.0.3.\n\n```\n\u003c?php\n\n$list = new \\Sokil\\DataType\\WeightList([\n    '10.0.0.1' =\u003e 60,\n    '10.0.0.2' =\u003e 30,\n    '10.0.0.3' =\u003e 10,\n]);\n\n$ipAddress = $list-\u003egetRandomValue();\n```\n    \nNow we have address on every request relatively to it's weight.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsokil%2Fphp-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsokil%2Fphp-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsokil%2Fphp-list/lists"}