{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/10933","labels_url":"https://api.github.com/repos/laravel/framework/issues/10933/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/10933/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/10933/events","html_url":"https://github.com/laravel/framework/pull/10933","id":116803533,"number":10933,"title":"[5.2] Proposal: string wrapper","user":{"login":"acasar","id":6329543,"avatar_url":"https://avatars.githubusercontent.com/u/6329543?v=3","gravatar_id":"","url":"https://api.github.com/users/acasar","html_url":"https://github.com/acasar","followers_url":"https://api.github.com/users/acasar/followers","following_url":"https://api.github.com/users/acasar/following{/other_user}","gists_url":"https://api.github.com/users/acasar/gists{/gist_id}","starred_url":"https://api.github.com/users/acasar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acasar/subscriptions","organizations_url":"https://api.github.com/users/acasar/orgs","repos_url":"https://api.github.com/users/acasar/repos","events_url":"https://api.github.com/users/acasar/events{/privacy}","received_events_url":"https://api.github.com/users/acasar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-13T16:36:57Z","updated_at":"2015-11-13T17:33:19Z","closed_at":"2015-11-13T17:07:10Z","pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/10933","html_url":"https://github.com/laravel/framework/pull/10933","diff_url":"https://github.com/laravel/framework/pull/10933.diff","patch_url":"https://github.com/laravel/framework/pull/10933.patch"},"body":"This PR proposes a string wrapper (similar to how collections wrap arrays). Basically, I had to deal with a lot of string manipulation in a project recently, so I wrote this class to make my code more readable and avoid all of that UTF-8 and needle-haystack problems. Would you consider adding something like that into core? If not, I'll just make a package for anyone who'd like to use it.\r\n\r\nI also added a ``str`` helper, since we already have a ``collect`` helper for collections. Below are some real world scenarios that this PR helps to solve:\r\n\r\n```php\r\n// lets say that a user provides tags in the following format: \"tag1, tag2, tag3\"\r\n\r\nstr($tags)->words()->each(function ($tag) {\r\n    // do something with a tag here\r\n});\r\n```\r\n\r\n```php\r\n// we can avoid nesting str functions and needle-haystack problems\r\n\r\nstr('  some text  ')->trim()->substring(0, 4); // returns \"some\"\r\n```\r\n\r\n```php\r\n// lets say we have a slug \"my-blog-title-4\" and we need to find the index \"4\"\r\n\r\n$lastIndex = str($lastSlug)->explode('-')->last();\r\n```\r\n\r\n```php\r\n// lets say we have some custom \"colon separated\" multi line file that we need to import\r\n\r\nstr($content)->lines()->each(function ($row) {\r\n    $data = str($row)->explode(':');\r\n    // do something with data here\r\n});\r\n```\r\n\r\netc.\r\n"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/156495607","html_url":"https://github.com/laravel/framework/pull/10933#issuecomment-156495607","issue_url":"https://api.github.com/repos/laravel/framework/issues/10933","id":156495607,"user":{"login":"JosephSilber","id":1403741,"avatar_url":"https://avatars.githubusercontent.com/u/1403741?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephSilber","html_url":"https://github.com/JosephSilber","followers_url":"https://api.github.com/users/JosephSilber/followers","following_url":"https://api.github.com/users/JosephSilber/following{/other_user}","gists_url":"https://api.github.com/users/JosephSilber/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephSilber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephSilber/subscriptions","organizations_url":"https://api.github.com/users/JosephSilber/orgs","repos_url":"https://api.github.com/users/JosephSilber/repos","events_url":"https://api.github.com/users/JosephSilber/events{/privacy}","received_events_url":"https://api.github.com/users/JosephSilber/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T17:33:19Z","updated_at":"2015-11-13T17:33:19Z","body":"@acasar if you turn that into a package, I'll be the first one to get it."}}