Simplify Block::getBy and Block::getByName
authorThalia <thalia.e.chan@googlemail.com>
Thu, 21 Mar 2019 22:23:31 +0000 (22:23 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Fri, 22 Mar 2019 19:19:41 +0000 (19:19 +0000)
Block::getBlocker always returns a User, so there is no need for
these methods to check.

Change-Id: I0319f0aee8d3fb3c89e8f63ee2f4ba05c8d36482

includes/Block.php

index 0693650..40a48ce 100644 (file)
@@ -1032,10 +1032,7 @@ class Block {
         * @return int (0 for foreign users)
         */
        public function getBy() {
-               $blocker = $this->getBlocker();
-               return ( $blocker instanceof User )
-                       ? $blocker->getId()
-                       : 0;
+               return $this->getBlocker()->getId();
        }
 
        /**
@@ -1044,10 +1041,7 @@ class Block {
         * @return string
         */
        public function getByName() {
-               $blocker = $this->getBlocker();
-               return ( $blocker instanceof User )
-                       ? $blocker->getName()
-                       : (string)$blocker; // username
+               return $this->getBlocker()->getName();
        }
 
        /**