ammarfaizi2 / KlikBCA

KlikBCA Scraper
GNU General Public License v2.0
79 stars 25 forks source link

[GIT PULL] refactor: remove if-else for setProxy method #4

Closed fzn0x closed 2 years ago

fzn0x commented 2 years ago

This pull request removes the use of if else since $optDef[CURLOPT_PROXY] = $this->proxy; are passed if $this->proxy internal variable is string (there's nothing to do with NULL or any non-string value). Resolving my own review on this PR https://github.com/ammarfaizi2/KlikBCA/pull/3

ammarfaizi2 commented 2 years ago

Thank you!

I love the idea of removing the if-else statement here. But I want to reword the commit message.

I pulled this, but the commit message is reworded. Also, for the pull requests, I personally use the Linux kernel style. It's the same with liburing's pull request guide here: https://github.com/axboe/liburing/blob/master/.github/pull_request_template.md

I will put that document as contributing guidelines and pull requests template later.

That if-else statement is just redundant, it looks like this now:

From 5388b8abc45b4c938b153dde8e72879fcc61ba26 Mon Sep 17 00:00:00 2001
From: Muhammad Fauzan <fncolon@pm.me>
Date: Sat, 14 May 2022 18:43:30 +0700
Subject: [PATCH] KlikBCA: Remove if-else in the `setProxy()` method

The if-else statement in the `setProxy()` method is redundant because
we are going to set `$this->proxy` with a NULL if no argument is
specified.

[ammarfaizi2: Reword the commit message.]

Link: https://github.com/ammarfaizi2/KlikBCA/pull/4
Link: https://github.com/ammarfaizi2/KlikBCA/commit/c176fbbadfba.patch
Signed-off-by: Muhammad Fauzan <fncolon@pm.me>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/KlikBCA/KlikBCA.php | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/KlikBCA/KlikBCA.php b/src/KlikBCA/KlikBCA.php
index b5ab7c0..f826708 100644
--- a/src/KlikBCA/KlikBCA.php
+++ b/src/KlikBCA/KlikBCA.php
@@ -355,10 +355,7 @@ final class KlikBCA
     */
    public function setProxy($proxy = NULL)
    {
-       if (is_string($proxy))
-           $this->proxy = $proxy;
-       else
-           $this->proxy = NULL;
+       $this->proxy = $proxy;
    }

    /**
-- 
2.32.0