original_string: protected function getArrayAndKeyName(string $fieldName, string $key): array
      {
          if (!in_array($key, ['filters', 'sorts'], true)) {
              throw new InvalidArgumentException('Key must be one of [filters, sorts]');
          }
          if (str_contains($fieldName, '.')) {
              $path         = explode('.', $fieldName);
              $name         = array_pop($path);
              $relationPath = implode('.', $path);
              $array        = array_get($this->relations, "$relationPath.$key", []);
          } else {
              $name  = $fieldName;
              $array = ($key === 'filters') ? $this->filters : $this->sorts;
          }
          return [$name, $array];
      }
code: protected function getArrayAndKeyName(string $fieldName, string $key): array
      {
          if (!in_array($key, ['filters', 'sorts'], true)) {
              throw new InvalidArgumentException('Key must be one of [filters, sorts]');
          }
          if (str_contains($fieldName, '.')) {
              $path         = explode('.', $fieldName);
              $name         = array_pop($path);
              $relationPath = implode('.', $path);
              $array        = array_get($this->relations, "$relationPath.$key", []);
          } else {
              $name  = $fieldName;
              $array = ($key === 'filters') ? $this->filters : $this->sorts;
          }
          return [$name, $array];
      }
code_tokens: protected function getArrayAndKeyName ( string $ fieldName , string $ key ) : array { if ( ! in_array ( $ key , [ 'filters' , 'sorts' ] , true ) ) { throw new InvalidArgumentException ( 'Key must be one of [filters, sorts]' ) ; } if ( str_contains ( $ fieldName , '.' ) ) { $ path = explode ( '.' , $ fieldName ) ; $ name = array_pop ( $ path ) ; $ relationPath = implode ( '.' , $ path ) ; $ array = array_get ( $ this -> relations , "$relationPath.$key" , [ ] ) ; } else { $ name = $ fieldName ; $ array = ( $ key === 'filters' ) ? $ this -> filters : $ this -> sorts ; } return [ $ name , $ array ] ; }
docstring: Helper function to figure out which array to use
  
  @param string $fieldName Field name
  @param string $key       filters or sorts
  
  @throws InvalidArgumentException
  
  @return array
docstring_tokens: Helper function to figure out which array to use