original_string: public function detectEnvName()
      {
          // Detect from local env file
          if ($this->envFile && is_file($this->envFile)) {
              $this->name = require $this->envFile;
              if ($this->name) {
                  return;
              }
          }
  
          // Return if env name is detected, or, or continue detecting by IP
          if ($this->detector && $this->name = call_user_func($this->detector)) {
              return;
          }
  
          // Executes in web server, like Apache, Nginx
          if (isset($this->server['SERVER_ADDR'])) {
              $ip = $this->server['SERVER_ADDR'];
              if (isset($this->ipMap[$ip])) {
                  $this->name = $this->ipMap[$ip];
              } else {
                  $this->name = 'prod';
              }
              return;
          }
  
          // Executes in CLI
          if (php_sapi_name() == 'cli' && $ips = $this->getServerIps()) {
              foreach ($ips as $ip) {
                  if (isset($this->ipMap[$ip])) {
                      $this->name = $this->ipMap[$ip];
                      return;
                  }
              }
          }
  
          $this->name = 'prod';
          return;
      }
code: public function detectEnvName()
      {
          // Detect from local env file
          if ($this->envFile && is_file($this->envFile)) {
              $this->name = require $this->envFile;
              if ($this->name) {
                  return;
              }
          }
  
          // Return if env name is detected, or, or continue detecting by IP
          if ($this->detector && $this->name = call_user_func($this->detector)) {
              return;
          }
  
          // Executes in web server, like Apache, Nginx
          if (isset($this->server['SERVER_ADDR'])) {
              $ip = $this->server['SERVER_ADDR'];
              if (isset($this->ipMap[$ip])) {
                  $this->name = $this->ipMap[$ip];
              } else {
                  $this->name = 'prod';
              }
              return;
          }
  
          // Executes in CLI
          if (php_sapi_name() == 'cli' && $ips = $this->getServerIps()) {
              foreach ($ips as $ip) {
                  if (isset($this->ipMap[$ip])) {
                      $this->name = $this->ipMap[$ip];
                      return;
                  }
              }
          }
  
          $this->name = 'prod';
          return;
      }
code_tokens: public function detectEnvName ( ) { // Detect from local env file if ( $ this -> envFile && is_file ( $ this -> envFile ) ) { $ this -> name = require $ this -> envFile ; if ( $ this -> name ) { return ; } } // Return if env name is detected, or, or continue detecting by IP if ( $ this -> detector && $ this -> name = call_user_func ( $ this -> detector ) ) { return ; } // Executes in web server, like Apache, Nginx if ( isset ( $ this -> server [ 'SERVER_ADDR' ] ) ) { $ ip = $ this -> server [ 'SERVER_ADDR' ] ; if ( isset ( $ this -> ipMap [ $ ip ] ) ) { $ this -> name = $ this -> ipMap [ $ ip ] ; } else { $ this -> name = 'prod' ; } return ; } // Executes in CLI if ( php_sapi_name ( ) == 'cli' && $ ips = $ this -> getServerIps ( ) ) { foreach ( $ ips as $ ip ) { if ( isset ( $ this -> ipMap [ $ ip ] ) ) { $ this -> name = $ this -> ipMap [ $ ip ] ; return ; } } } $ this -> name = 'prod' ; return ; }
docstring: Detect environment by server IP
docstring_tokens: Detect environment by server IP