diff --git a/restrict_by_ip.module b/restrict_by_ip.module
index 682c4a1..f1c9bdb 100644
--- a/restrict_by_ip.module
+++ b/restrict_by_ip.module
@@ -104,7 +104,7 @@ function restrict_by_ip_form_alter(&$form, $form_state, $form_id) {
 function restrict_by_ip_user_profile_validate($form, &$form_state) {
   $ip_tools = \Drupal::service('restrict_by_ip.ip_tools');
   $ips = $form_state->getvalue('restrict_by_ip_address');
-  if (strlen($ips) > 0) {
+  if (!empty($ips)) {
     foreach (explode(';', $ips) as $ip) {
       try {
         $ip_tools->validateIP($ip);
@@ -124,7 +124,7 @@ function restrict_by_ip_user_profile_submit($form, &$form_state) {
   $user = $form_state->getFormObject()->getEntity();
   $ips = $form_state->getValue('restrict_by_ip_address');
 
-  if (strlen($ips) > 0) {
+  if (!empty($ips)) {
     $config->set('user.' . $user->id(), $ips)->save();
   }
   else {
@@ -154,7 +154,7 @@ function restrict_by_ip_role_check(&$user){
     $form_name = _restrict_by_ip_hash_role_name($name);
     $ranges = variable_get('restrict_by_ip_role_' . $form_name, '');
     // Only check IP if an IP restriction is set for this role
-    if (strlen($ranges) > 0) {
+    if (!empty($ranges)) {
       $ipaddresses = explode(';', $ranges);
       $match = FALSE;
       foreach ($ipaddresses as $ipaddress) {
@@ -185,4 +185,4 @@ function restrict_by_ip_user_load($users) {
       $user->removeRole($role);
     }
   }
-}
\ No newline at end of file
+}
diff --git a/src/Form/LoginSettingsForm.php b/src/Form/LoginSettingsForm.php
index 9592434..c9ca60e 100644
--- a/src/Form/LoginSettingsForm.php
+++ b/src/Form/LoginSettingsForm.php
@@ -78,7 +78,7 @@ class LoginSettingsForm extends ConfigFormBase {
   public function validateForm(array &$form, FormStateInterface $form_state) {
     parent::validateForm($form, $form_state);
 
-    if (strlen($form_state->getValue('restrict_by_ip_login_range')) > 0) {
+    if (!empty($form_state->getValue('restrict_by_ip_login_range'))) {
       $ip_addresses = explode(";", $form_state->getValue('restrict_by_ip_login_range'));
       foreach ($ip_addresses as $ip) {
         try {
diff --git a/src/Form/RoleSettingsForm.php b/src/Form/RoleSettingsForm.php
index edb2ba9..7ce4eb3 100644
--- a/src/Form/RoleSettingsForm.php
+++ b/src/Form/RoleSettingsForm.php
@@ -81,7 +81,7 @@ class RoleSettingsForm extends ConfigFormBase {
     parent::validateForm($form, $form_state);
 
     foreach ($form_state->getValues() as $key => $value) {
-      if (strpos($key, 'restrict_by_ip_role_') !== FALSE && strlen($value) > 0) {
+      if (strpos($key, 'restrict_by_ip_role_') !== FALSE && !empty($value)) {
         $ip_addresses = explode(";", $value);
         foreach ($ip_addresses as $ip) {
           try {
diff --git a/src/Form/UserSettingsForm.php b/src/Form/UserSettingsForm.php
index 738514e..3627b1f 100644
--- a/src/Form/UserSettingsForm.php
+++ b/src/Form/UserSettingsForm.php
@@ -89,7 +89,7 @@ class UserSettingsForm extends ConfigFormBase {
 
     // Validation for existing restrictions.
     foreach ($form_state->getValues() as $key => $value) {
-      if (strpos($key, 'restrict_by_ip_user_') !== FALSE && strlen($value) > 0) {
+      if (strpos($key, 'restrict_by_ip_user_') !== FALSE && !empty($value)) {
         $ip_addresses = explode(";", $value);
         foreach ($ip_addresses as $ip) {
           try {
@@ -103,7 +103,7 @@ class UserSettingsForm extends ConfigFormBase {
     }
 
     // Validation for new restriction.
-    if (strlen($form_state->getValue('name')) > 0) {
+    if (!empty($form_state->getValue('name'))) {
       // Validate no existing restriction.
       if ($config->get('user.' . $form_state->getValue('name')) !== NULL) {
         $form_state->setErrorByName('name', $this->t('Restriction for that user already exist.'));
@@ -136,7 +136,7 @@ class UserSettingsForm extends ConfigFormBase {
         continue;
       }
 
-      if (strlen($value) > 0) {
+      if (!empty($value)) {
         $config->set(str_replace('restrict_by_ip_user_', 'user.', $key), $value);
       }
       else {
@@ -145,7 +145,7 @@ class UserSettingsForm extends ConfigFormBase {
     }
 
     // New restriction.
-    if (strlen($form_state->getValue('name')) > 0) {
+    if (!empty($form_state->getValue('name'))) {
       $config->set('user.' . $form_state->getValue('name'), $form_state->getValue('restriction'));
     }
 
diff --git a/src/LoginFirewall.php b/src/LoginFirewall.php
index 560378c..822688e 100644
--- a/src/LoginFirewall.php
+++ b/src/LoginFirewall.php
@@ -97,7 +97,7 @@ class LoginFirewall implements LoginFirewallInterface {
     $global_data = $this->config->get('login_range');
 
     // If there is no global IP restriction configured, we allow all.
-    if (strlen($global_data) == 0) {
+    if (empty($global_data)) {
       return NULL;
     }
 
@@ -118,7 +118,7 @@ class LoginFirewall implements LoginFirewallInterface {
     $user_data = $this->config->get('user.' . $account->id());
 
     // If there is no user IP restriction configured, we allow all.
-    if (strlen($user_data) == 0) {
+    if (empty($user_data)) {
       return NULL;
     }
 
diff --git a/src/RoleFirewall.php b/src/RoleFirewall.php
index 0c2f7fb..218aa9b 100644
--- a/src/RoleFirewall.php
+++ b/src/RoleFirewall.php
@@ -44,7 +44,7 @@ class RoleFirewall implements RoleFirewallInterface {
     foreach ($roles as $name) {
       $role_data = $this->config->get('role.' . $name);
 
-      if (strlen($role_data) == 0) {
+      if (empty($role_data)) {
         continue;
       }
 
