original_string: private function _add_primary(array &$cfg): void
    {
      // Inserting a row without primary when primary is needed and no auto-increment
      if (
        !empty($cfg['primary']) &&
        empty($cfg['auto_increment']) &&
        (($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
        (count($cfg['values']) === (count($cfg['fields']) - 1))
      ){
        $val = false;
        switch ( $cfg['primary_type'] ){
          case 'int':
            $val = random_int(
              ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] - 3 : 1) / 2),
              ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] : 1) / 2)
            );
            break;
          case 'binary':
            if ( $cfg['primary_length'] === 16 ){
              x::log($cfg['tables'], 'add_options');
              $val = $this->get_uid();
              x::log($val, 'add_options');
            }
            break;
        }
        if ( $val ){
          array_splice($cfg['values'], $idx, 0, $val);
          $this->set_last_insert_id($val);
          x::log(['v' => $cfg['values'], 'f' => $cfg['fields']], 'add_options');
        }
      }
    }
code: private function _add_primary(array &$cfg): void
    {
      // Inserting a row without primary when primary is needed and no auto-increment
      if (
        !empty($cfg['primary']) &&
        empty($cfg['auto_increment']) &&
        (($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
        (count($cfg['values']) === (count($cfg['fields']) - 1))
      ){
        $val = false;
        switch ( $cfg['primary_type'] ){
          case 'int':
            $val = random_int(
              ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] - 3 : 1) / 2),
              ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] : 1) / 2)
            );
            break;
          case 'binary':
            if ( $cfg['primary_length'] === 16 ){
              x::log($cfg['tables'], 'add_options');
              $val = $this->get_uid();
              x::log($val, 'add_options');
            }
            break;
        }
        if ( $val ){
          array_splice($cfg['values'], $idx, 0, $val);
          $this->set_last_insert_id($val);
          x::log(['v' => $cfg['values'], 'f' => $cfg['fields']], 'add_options');
        }
      }
    }
code_tokens: private function _add_primary ( array & $ cfg ) : void { // Inserting a row without primary when primary is needed and no auto-increment if ( ! empty ( $ cfg [ 'primary' ] ) && empty ( $ cfg [ 'auto_increment' ] ) && ( ( $ idx = array_search ( $ cfg [ 'primary' ] , $ cfg [ 'fields' ] , true ) ) > - 1 ) && ( count ( $ cfg [ 'values' ] ) === ( count ( $ cfg [ 'fields' ] ) - 1 ) ) ) { $ val = false ; switch ( $ cfg [ 'primary_type' ] ) { case 'int' : $ val = random_int ( ceil ( 10 ** ( $ cfg [ 'primary_length' ] > 3 ? $ cfg [ 'primary_length' ] - 3 : 1 ) / 2 ) , ceil ( 10 ** ( $ cfg [ 'primary_length' ] > 3 ? $ cfg [ 'primary_length' ] : 1 ) / 2 ) ) ; break ; case 'binary' : if ( $ cfg [ 'primary_length' ] === 16 ) { x :: log ( $ cfg [ 'tables' ] , 'add_options' ) ; $ val = $ this -> get_uid ( ) ; x :: log ( $ val , 'add_options' ) ; } break ; } if ( $ val ) { array_splice ( $ cfg [ 'values' ] , $ idx , 0 , $ val ) ; $ this -> set_last_insert_id ( $ val ) ; x :: log ( [ 'v' => $ cfg [ 'values' ] , 'f' => $ cfg [ 'fields' ] ] , 'add_options' ) ; } } }
docstring: Adds a random primary value when it is absent from the set and present in the fields
  @param array $cfg
docstring_tokens: Adds a random primary value when it is absent from the set and present in the fields