{"id":20737112,"url":"https://github.com/phpexpertsinc/colorspeaker","last_synced_at":"2025-08-28T22:14:42.117Z","repository":{"id":57040337,"uuid":"191460079","full_name":"PHPExpertsInc/ColorSpeaker","owner":"PHPExpertsInc","description":"An easy-to-use converter for different types of color models.","archived":false,"fork":false,"pushed_at":"2020-09-25T03:17:18.000Z","size":50,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T01:23:33.504Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://stitcher.io/blog/tests-and-types","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/PHPExpertsInc.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":"2019-06-11T22:40:00.000Z","updated_at":"2020-09-25T03:13:19.000Z","dependencies_parsed_at":"2022-08-24T00:50:54.830Z","dependency_job_id":null,"html_url":"https://github.com/PHPExpertsInc/ColorSpeaker","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPExpertsInc%2FColorSpeaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPExpertsInc%2FColorSpeaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPExpertsInc%2FColorSpeaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPExpertsInc%2FColorSpeaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHPExpertsInc","download_url":"https://codeload.github.com/PHPExpertsInc/ColorSpeaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243023775,"owners_count":20223493,"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-17T06:13:34.347Z","updated_at":"2025-03-11T11:26:19.045Z","avatar_url":"https://github.com/PHPExpertsInc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ColorSpeaker\n\n[![Travis CI](https://travis-ci.com/phpexpertsinc/ColorSpeaker.svg?branch=master)](https://travis-ci.com/phpexpertsinc/ColorSpeaker)[![Maintainability](https://api.codeclimate.com/v1/badges/503cba0c53eb262c947a/maintainability)](https://codeclimate.com/github/phpexpertsinc/SimpleDTO/maintainability)\n[![Maintainability](https://api.codeclimate.com/v1/badges/1dff9e08f54516c41e4d/maintainability)](https://codeclimate.com/github/phpexpertsinc/ColorSpeaker/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/1dff9e08f54516c41e4d/test_coverage)](https://codeclimate.com/github/phpexpertsinc/ColorSpeaker/test_coverage)\n\nColorSpeaker is a PHP Experts, Inc., Project is an easy-to-use converter for different types of color models.\n\nIt aims to support all major color models: RGB, CSS hex codes, HSL and HSV.\n\n## Installation\n\nVia Composer\n\n```bash\ncomposer require phpexperts/color-speaker\n```\n\n## Usage\n\nInitialize it with 3 standard RGB integers:\n```php\n$rgbSpeaker = ColorSpeaker::fromRGB(123, 111, 55);\n$hexSpeaker = ColorSpeaker::fromHexCode('#7B6F37');\n$hslSpeaker = ColorSpeaker::fromHSL(49, 38, 35);\n```\nIt can easily be used as a string for css-compatible output:\n```php\n$csv = \".box { background-color: $rgbSpeaker; }\";\n// .box { background-color: rgb(123, 111, 55); }\n$csvHex = \".box { background-color: $hexSpeaker; }\";\n// .box { background-color: #7B6F37; }\n```\nYou can also fetch the RGBColor and the HexColor directly:\n```php\n$rgbColor = $rgbSpeaker-\u003etoRGB();\n/*\n   (string) $rgbColor === rgb(123, 111, 55);\n\n   SimpleDTO =\u003e {\n       'red'   =\u003e 123,\n       'green' =\u003e 111,\n       'blue'  =\u003e 55\n   };\n*/\n```\n\nSee the [**SimpleDTO Project**](https://github.com/phpexpertsinc/simple-dto) for more.\n\nYou can also export to different color formats:\n```php\n$hexColor = $rgbSpeaker-\u003etoHexCode();\n/**\n    (string) $hexColor === #7B6F37\n\n    SimpleDTO =\u003e {\n        'hex' =\u003e '#7B6F37\n    }\n**/\n```\n\nAll colors serializable and easily converted to JSON objects:\n\n```php\n$linguist = ColorSpeaker::fromHexCode('#7B6F37');\n$rgbColor = $linguist-\u003etoRGB();\necho json_encode($rgbColor, JSON_PRETTY_PRINT);\n/**\n{\n    \"red\": 123,\n    \"green\": 111,\n    \"blue\": 55\n}\n**/\n```\n\n# Use cases\n\nPHPExperts\\ColorSpeaker\\ColorSpeaker  \n ✔ Can be constructed from an RGBColor  \n ✔ Can be constructed from a HexColor  \n ✔ Can be constructed from an HSLColor  \n ✔ From RGB: Will only accept integers between 0 and 255, inclusive  \n ✔ From CSS Hex: Will only accept a valid 3 or 6 digit Hex color string, \n   starting with a \"#\" sign  \n ✔ Can return an RGBColor  \n ✔ Can return a CSSHexColor  \n ✔ Can return an HSLColor  \n ✔ Can be outputted as a CSS string  \n\nPHPExperts\\ColorSpeaker\\DTOs\\RGBColor  \n ✔ Will only accept integers between 0 and 255, inclusive  \n ✔ Will only accept literal integers  \n ✔ Can be constructed with a zero-indexed array  \n ✔ Can be outputted as a CSS string  \n\nPHPExperts\\ColorSpeaker\\DTOs\\CSSHexColor  \n ✔ Can assert if a string is a valid CSS hex color  \n ✔ The hex code must start with a \"#\" sign  \n ✔ Will only accept three digit and six digit hex codes  \n ✔ Can be outputted as a CSS string  \n\nPHPExperts\\ColorSpeaker\\DTOs\\HSLColor  \n ✔ Will only accept a valid HSL geometry of percentages or percent-integers  \n ✔ Can be constructed with a zero-indexed array  \n ✔ Can be constructed with integers  \n ✔ Can be outputted as a CSS string  \n\n## Testing\n\n```bash\nphpunit --testdox\n```\n\n# Contributors\n\n[Theodore R. Smith](https://www.phpexperts.pro/]) \u003ctheodore@phpexperts.pro\u003e  \nGPG Fingerprint: 4BF8 2613 1C34 87AC D28F  2AD8 EB24 A91D D612 5690  \nCEO: PHP Experts, Inc.\n\nA **big** shoutout to https://www.w3schools.com/colors/colors_converter.asp.\nThat *wonderful* color converter made this project's development 70% easier!\n\n## License\n\nMIT license. Please see the [license file](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpexpertsinc%2Fcolorspeaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpexpertsinc%2Fcolorspeaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpexpertsinc%2Fcolorspeaker/lists"}