{"action":"created","issue":{"url":"https://api.github.com/repos/Seldaek/monolog/issues/801","repository_url":"https://api.github.com/repos/Seldaek/monolog","labels_url":"https://api.github.com/repos/Seldaek/monolog/issues/801/labels{/name}","comments_url":"https://api.github.com/repos/Seldaek/monolog/issues/801/comments","events_url":"https://api.github.com/repos/Seldaek/monolog/issues/801/events","html_url":"https://github.com/Seldaek/monolog/pull/801","id":157645583,"number":801,"title":"Add fluent setters for parameters in the slack handler","user":{"login":"EspadaV8","id":115825,"avatar_url":"https://avatars.githubusercontent.com/u/115825?v=3","gravatar_id":"","url":"https://api.github.com/users/EspadaV8","html_url":"https://github.com/EspadaV8","followers_url":"https://api.github.com/users/EspadaV8/followers","following_url":"https://api.github.com/users/EspadaV8/following{/other_user}","gists_url":"https://api.github.com/users/EspadaV8/gists{/gist_id}","starred_url":"https://api.github.com/users/EspadaV8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EspadaV8/subscriptions","organizations_url":"https://api.github.com/users/EspadaV8/orgs","repos_url":"https://api.github.com/users/EspadaV8/repos","events_url":"https://api.github.com/users/EspadaV8/events{/privacy}","received_events_url":"https://api.github.com/users/EspadaV8/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-31T11:05:32Z","updated_at":"2016-05-31T11:47:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Seldaek/monolog/pulls/801","html_url":"https://github.com/Seldaek/monolog/pull/801","diff_url":"https://github.com/Seldaek/monolog/pull/801.diff","patch_url":"https://github.com/Seldaek/monolog/pull/801.patch"},"body":"The current slack handler has way too many constructor parameters and no clear order as to their position. This makes it confusing to work out what is actually trying to be set when constructing a new class, e.g,\r\n\r\n```php\r\n$slack = new SlackHandler(\r\n    'xoxp-0000000000-1111111111-22222222222-3333333333',\r\n    '#general',\r\n    'Monolog',\r\n    false,\r\n    null,\r\n    Logger::ERROR,\r\n    true,\r\n    false,\r\n    true\r\n);\r\n```\r\n\r\nThis PR makes things a bit easier by adding some fluent setters into the class.\r\n\r\n```php\r\n$slack = new SlackHandler(\r\n        'xoxp-0000000000-1111111111-22222222222-3333333333',\r\n        '#general',\r\n        'Monolog'\r\n    )\r\n    ->setErrorLevel(Logger::ERROR)\r\n    ->useAttachment(false)\r\n    ->includeContextAndExtra(true);\r\n```\r\n\r\nIt would be nice to cut back the number of constructor parameters and reorder them to make a bit more sense\r\n\r\n```php\r\n// Current\r\npublic function __construct(\r\n    $token,\r\n    $channel,\r\n    $username = 'Monolog',\r\n    $useAttachment = true,\r\n    $iconEmoji = null,\r\n    $level = Logger::CRITICAL,\r\n    $bubble = true,\r\n    $useShortAttachment = false,\r\n    $includeContextAndExtra = false\r\n)\r\n\r\n// Proposed\r\npublic function __construct(\r\n    $token,\r\n    $channel,\r\n    $username = 'Monolog',\r\n    $level = Logger::CRITICAL,\r\n    $bubble = true\r\n)\r\n```\r\n\r\nSince that would be a fairly major breaking change though I've not included it in this PR. If it would be okay to do in another PR I'll open one up for it.\r\n\r\n\r\nI've included scalar type hints for the methods because the file include the `declare(strict_types=1);` which is only valid for PHP7 so I assume that is okay. If not then I can easily remove them."},"comment":{"url":"https://api.github.com/repos/Seldaek/monolog/issues/comments/222665475","html_url":"https://github.com/Seldaek/monolog/pull/801#issuecomment-222665475","issue_url":"https://api.github.com/repos/Seldaek/monolog/issues/801","id":222665475,"user":{"login":"EspadaV8","id":115825,"avatar_url":"https://avatars.githubusercontent.com/u/115825?v=3","gravatar_id":"","url":"https://api.github.com/users/EspadaV8","html_url":"https://github.com/EspadaV8","followers_url":"https://api.github.com/users/EspadaV8/followers","following_url":"https://api.github.com/users/EspadaV8/following{/other_user}","gists_url":"https://api.github.com/users/EspadaV8/gists{/gist_id}","starred_url":"https://api.github.com/users/EspadaV8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EspadaV8/subscriptions","organizations_url":"https://api.github.com/users/EspadaV8/orgs","repos_url":"https://api.github.com/users/EspadaV8/repos","events_url":"https://api.github.com/users/EspadaV8/events{/privacy}","received_events_url":"https://api.github.com/users/EspadaV8/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T11:47:22Z","updated_at":"2016-05-31T11:47:22Z","body":"A big problem with using array for arguments is that it's even harder to work out what are valid options. There's no other way except looking at the code/API docs to see what is allowed for each constructor then. At least with constructor parameters you can get hints from your IDE or just look at the method signature."}}
{"actor":{"display_login":"EspadaV8"}}