{"id":33974347,"url":"https://github.com/cornejong/southcoast-helpers","last_synced_at":"2025-12-13T01:42:28.830Z","repository":{"id":57056154,"uuid":"168493047","full_name":"cornejong/southcoast-helpers","owner":"cornejong","description":"A Collection of helper classes for PHP","archived":false,"fork":false,"pushed_at":"2025-06-03T12:19:37.000Z","size":111,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-27T16:32:28.703Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/cornejong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-31T08:51:28.000Z","updated_at":"2024-05-26T15:45:31.000Z","dependencies_parsed_at":"2022-08-24T14:52:54.080Z","dependency_job_id":null,"html_url":"https://github.com/cornejong/southcoast-helpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cornejong/southcoast-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornejong%2Fsouthcoast-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornejong%2Fsouthcoast-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornejong%2Fsouthcoast-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornejong%2Fsouthcoast-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cornejong","download_url":"https://codeload.github.com/cornejong/southcoast-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornejong%2Fsouthcoast-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27697880,"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","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"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":[],"created_at":"2025-12-13T01:42:28.321Z","updated_at":"2025-12-13T01:42:28.819Z","avatar_url":"https://github.com/cornejong.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SouthCoast | Helpers\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d07fb7f35120486cae0a04da67dd8bd2)](https://app.codacy.com/app/corne.dejong/southcoast-helpers?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=cornejong/southcoast-helpers\u0026utm_campaign=Badge_Grade_Dashboard)\n\nA Collection of helper classes for PHP\n\nCould be installed via composer:\n```BASH\n$ composer require southcoast/helpers:dev-master\n```\n\nOr by manually downloading the .zip file.\n\n## Array Helper\n\n### ```ArrayHelper::Map(array $map, array $array): array;```\n\n```PHP\n$map        array   The mapping \n$array      array   The original array where data should come from\nReturns     array   The mapped array\n```\n\nThis method allows you to map an existing array to a new one.\nIt has support for dot notation for use of multidimensional arrays. Both for the 'field' and the mapping keys\n\nAccepted keys in the mapping array:\n```PHP\n[\n    'field' =\u003e 'The key to the field from the original $array',\n    'alt_field' =\u003e 'An alternative key in the original $array for when the primary field is not found or returns null',\n    'value' =\u003e 'A static value, or mutation of the value, This will over ride the value of the primary field',\n    'or' =\u003e 'A static value that should be used',\n    'add' =\u003e 'If the field should be used or not, accepts true or false values'\n]\n```\n\nMapping Example:\n```PHP\n$map = [\n    // The Key is the to be used key for the Array\n    // The value of 'field' is the value origin\n    'New_Name' =\u003e ['field' =\u003e 'old_name'],\n\n    // Add 'value' to add custom value or value mutation\n    'Email' =\u003e ['value' =\u003e 'Some Other Value'],\n    \n    // Add '.' separators for sub objects\n    'Email.primary' =\u003e ['field' =\u003e 'email'],\n    \n    // Use '0' for arrays\n    'Addresses.0.street' =\u003e ['field' =\u003e 'address_1_line_1'],\n    \n    // Get a value from a multidimensional source\n    'isDefault' =\u003e ['field' =\u003e 'meta.system.default'],\n    \n    // Add the 'or' field to supply a value that will used if the value from the original array is not found or null\n    'automated' =\u003e ['field' =\u003e 'system.automated', 'or' =\u003e 'nope, not automated']\n    \n    // Use the 'add' field to specify if this field should be added\n    'someAwesomeField' =\u003e ['field' =\u003e 'getMyValue', 'add' =\u003e false] // Wont be added\n    'someAwesomeField' =\u003e ['field' =\u003e 'getMyValue', 'add' =\u003e true] // Will be added\n    \n    // Add an alternative field to the mapping if the original field is missing or returned null\n    'arbitraryKey' =\u003e ['field' =\u003e 'getItFromHere', 'alt_field' =\u003e 'or_from_here', 'or' =\u003e 'a default value']\n];\n```\n\nExample: \n```PHP\n$array = [\n    'key_1' =\u003e 'value_1',\n    'key_2' =\u003e 'value_2',\n    'array' =\u003e [\n        'a_key_1' =\u003e 'a_value_1',\n        'a_key_2' =\u003e 'a_value_2',\n        'a_key_3' =\u003e null\n    ]\n];\n\n$map = [\n    'field_one' =\u003e ['field' =\u003e 'array.a_key_1'],\n    'field_two' =\u003e ['field' =\u003e 'key_1', 'add' =\u003e false],\n    'field_three' =\u003e ['value' =\u003e 'new_value'],\n    'field_four' =\u003e ['field' =\u003e 'array.a_key_5', 'alt_field' =\u003e 'key_2'],\n    'field_five' =\u003e 'This Value',\n    'array.a_field' =\u003e ['field' =\u003e 'array.a_key_3', 'or' =\u003e 'nope, no value'],\n    'array.0' =\u003e ['field' =\u003e 'array.a_key_2']\n];\n\n$result = ArrayHelper::map($map, $array);\n\n$result = [\n    /* The key 'field_one' had the value of array['a_key_1'] */\n    'field_one' =\u003e 'a_value_1',\n    /* The key 'field_two' was not added, because 'add' was false */\n    /* The key 'field_three' has a custom value */\n    'field_three' =\u003e 'new_value',\n    /* The key 'field_four' now bears the value of 'key_2' because 'array.a_key_5' could not be found */\n    'field_four' =\u003e 'value_2',\n    /* The key 'field_five' also carries a custom value */\n    'field_five' =\u003e 'This Value',\n    /* The key 'array' now contains an array */\n    'array' =\u003e [\n        /* With a key 'a_field' with the 'or' value because 'array.a_key_3' has a null value */\n        'a_field' =\u003e 'nope, no value',\n        /* Also a numeric key was added with the value of 'array.a_key_2' */\n        0 =\u003e 'a_value_2'\n    ]\n]\n```\n\n\n## Environment \nCreate a file called 'sc.env'.\nThis file should contain the following structure:\n\n```JSON\n{\n    \"dev\": true,\n    \"machine\": \"\u003cMachine ID/Developer ID\u003e\",\n    \"...\": \"Any other parameters you'd like to add to your environment\"\n}\n```\n\nIn your main php file load the env file.\n\n```PHP\n$path_to_env = './sc.env';\nEnv::load($path_to_env);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornejong%2Fsouthcoast-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcornejong%2Fsouthcoast-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornejong%2Fsouthcoast-helpers/lists"}