private function checkFieldIndex($fieldIndex): void
    {
        if (ctype_digit((string)$fieldIndex)) {
            if ($fieldIndex < 0 || $fieldIndex >= $this->numFields) {
                throw new exceptions\InvalidArgumentException(sprintf(
                    "%s: field number %d is not within range 0..%d",
                    __METHOD__,
                    $fieldIndex,
                    $this->numFields - 1
                ));
            }

        } elseif (is_string($fieldIndex)) {
            if (!isset($this->namesHash[$fieldIndex])) {
                throw new exceptions\InvalidArgumentException(
                    sprintf("%s: field name '%s' is not present", __METHOD__, $fieldIndex)
                );
            }

        } else {
            throw new exceptions\InvalidArgumentException(sprintf(
                "%s expects a field number or a field name, '%s' given",
                __METHOD__,
                is_object($fieldIndex) ? get_class($fieldIndex) : gettype($fieldIndex)
            ));
        }
    }
private function checkFieldIndex($fieldIndex): void
    {
        if (ctype_digit((string)$fieldIndex)) {
            if ($fieldIndex < 0 || $fieldIndex >= $this->numFields) {
                throw new exceptions\InvalidArgumentException(sprintf(
                    "%s: field number %d is not within range 0..%d",
                    __METHOD__,
                    $fieldIndex,
                    $this->numFields - 1
                ));
            }

        } elseif (is_string($fieldIndex)) {
            if (!isset($this->namesHash[$fieldIndex])) {
                throw new exceptions\InvalidArgumentException(
                    sprintf("%s: field name '%s' is not present", __METHOD__, $fieldIndex)
                );
            }

        } else {
            throw new exceptions\InvalidArgumentException(sprintf(
                "%s expects a field number or a field name, '%s' given",
                __METHOD__,
                is_object($fieldIndex) ? get_class($fieldIndex) : gettype($fieldIndex)
            ));
        }
    }
private function checkFieldIndex ( $ fieldIndex ) : void { if ( ctype_digit ( ( string ) $ fieldIndex ) ) { if ( $ fieldIndex < 0 || $ fieldIndex >= $ this -> numFields ) { throw new exceptions \ InvalidArgumentException ( sprintf ( "%s: field number %d is not within range 0..%d" , __METHOD__ , $ fieldIndex , $ this -> numFields - 1 ) ) ; } } elseif ( is_string ( $ fieldIndex ) ) { if ( ! isset ( $ this -> namesHash [ $ fieldIndex ] ) ) { throw new exceptions \ InvalidArgumentException ( sprintf ( "%s: field name '%s' is not present" , __METHOD__ , $ fieldIndex ) ) ; } } else { throw new exceptions \ InvalidArgumentException ( sprintf ( "%s expects a field number or a field name, '%s' given" , __METHOD__ , is_object ( $ fieldIndex ) ? get_class ( $ fieldIndex ) : gettype ( $ fieldIndex ) ) ) ; } }
Sanity check for field index

@param string|int $fieldIndex
@throws exceptions\InvalidArgumentException
Sanity check for field index