From becce6b7520912257c3d72697a3aefec9923a467 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Thu, 29 Nov 2018 20:59:46 +0100 Subject: Define an official codestyle and adhere to it. --- lib/PostProcessor/LWNProcessor.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib/PostProcessor/LWNProcessor.php') diff --git a/lib/PostProcessor/LWNProcessor.php b/lib/PostProcessor/LWNProcessor.php index 3e4fbbdd0..1028df100 100644 --- a/lib/PostProcessor/LWNProcessor.php +++ b/lib/PostProcessor/LWNProcessor.php @@ -31,7 +31,7 @@ class LWNProcessor implements ItemProcessorInterface * @param $user * @param $password */ - public function __construct($user, $password, IClientService $clientService) + public function __construct($user, $password, IClientService $clientService) { $this->user = $user; $this->password = $password; @@ -39,7 +39,7 @@ class LWNProcessor implements ItemProcessorInterface $this->cookieJar = new CookieJar(); } - private function login() + private function login() { if ($this->cookieJar->count() > 0) { return true; @@ -50,7 +50,8 @@ class LWNProcessor implements ItemProcessorInterface $client = $this->clientService->newClient(); $response = $client->post( - 'https://lwn.net/login', [ + 'https://lwn.net/login', + [ 'cookies' => $this->cookieJar, 'body' => [ 'Username' => $this->user, @@ -62,16 +63,18 @@ class LWNProcessor implements ItemProcessorInterface return ($response->getStatusCode() === 200 && $this->cookieJar->count() > 0); } - private function getBody($url) + private function getBody($url) { $client = $this->clientService->newClient(); $response = $client->get( - $url, [ + $url, + [ 'cookies' => $this->cookieJar ] ); $parser = new RuleParser( - $response->getBody(), [ + $response->getBody(), + [ 'body' => array( '//div[@class="ArticleText"]', ), @@ -85,7 +88,7 @@ class LWNProcessor implements ItemProcessorInterface return str_replace('href="/', 'href="https://lwn.net/', $articleBody); } - private function canHandle($url) + private function canHandle($url) { $regex = '%(?:https?://|//)?(?:www.)?lwn.net%'; @@ -100,7 +103,7 @@ class LWNProcessor implements ItemProcessorInterface * @param Item $item * @return bool */ - public function execute(Feed $feed, Item $item) + public function execute(Feed $feed, Item $item) { if ($this->canHandle($item->getUrl())) { $loggedIn = $this->login(); -- cgit v1.2.3