src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php
private function describeCount($rows = null)
    {
        if ($rows === null) {
            $rows = $this->fetchTargetRows();
        }

        if (!is_array($rows) && !($rows instanceof Traversable)) {
            throw new InvalidArgumentException(
                sprintf(
                    'The rows must be iterable; received %s',
                    is_object($rows) ? get_class($rows) : gettype($rows)
                )
            );
        }

        $cli   = $this->climate();
        $model = $this->targetModel();

        if (is_array($rows) || $rows instanceof Countable) {
            $count = count($rows);
        } elseif ($rows instanceof PDOStatement) {
            $count = $rows->rowCount();
        } else {
            $count = iterator_count($rows);
        }

        if ($count === 0) {
            $cli->comment('The object table is empty.');
            $cli->comment(
                sprintf('Only changing `%s` column.', $model->key())
            );

            return false;
        } elseif ($count === 1) {
            if (!$this->quiet()) {
                $cli->comment('The object table has 1 row.');
            }
        } else {
            if (!$this->quiet()) {
                $cli->comment(
                    sprintf('The object table has %s rows.', $count)
                );
            }
        }

        return true;
    }
private function describeCount($rows = null)
    {
        if ($rows === null) {
            $rows = $this->fetchTargetRows();
        }

        if (!is_array($rows) && !($rows instanceof Traversable)) {
            throw new InvalidArgumentException(
                sprintf(
                    'The rows must be iterable; received %s',
                    is_object($rows) ? get_class($rows) : gettype($rows)
                )
            );
        }

        $cli   = $this->climate();
        $model = $this->targetModel();

        if (is_array($rows) || $rows instanceof Countable) {
            $count = count($rows);
        } elseif ($rows instanceof PDOStatement) {
            $count = $rows->rowCount();
        } else {
            $count = iterator_count($rows);
        }

        if ($count === 0) {
            $cli->comment('The object table is empty.');
            $cli->comment(
                sprintf('Only changing `%s` column.', $model->key())
            );

            return false;
        } elseif ($count === 1) {
            if (!$this->quiet()) {
                $cli->comment('The object table has 1 row.');
            }
        } else {
            if (!$this->quiet()) {
                $cli->comment(
                    sprintf('The object table has %s rows.', $count)
                );
            }
        }

        return true;
    }
private function describeCount ( $ rows = null ) { if ( $ rows === null ) { $ rows = $ this -> fetchTargetRows ( ) ; } if ( ! is_array ( $ rows ) && ! ( $ rows instanceof Traversable ) ) { throw new InvalidArgumentException ( sprintf ( 'The rows must be iterable; received %s' , is_object ( $ rows ) ? get_class ( $ rows ) : gettype ( $ rows ) ) ) ; } $ cli = $ this -> climate ( ) ; $ model = $ this -> targetModel ( ) ; if ( is_array ( $ rows ) || $ rows instanceof Countable ) { $ count = count ( $ rows ) ; } elseif ( $ rows instanceof PDOStatement ) { $ count = $ rows -> rowCount ( ) ; } else { $ count = iterator_count ( $ rows ) ; } if ( $ count === 0 ) { $ cli -> comment ( 'The object table is empty.' ) ; $ cli -> comment ( sprintf ( 'Only changing `%s` column.' , $ model -> key ( ) ) ) ; return false ; } elseif ( $ count === 1 ) { if ( ! $ this -> quiet ( ) ) { $ cli -> comment ( 'The object table has 1 row.' ) ; } } else { if ( ! $ this -> quiet ( ) ) { $ cli -> comment ( sprintf ( 'The object table has %s rows.' , $ count ) ) ; } } return true ; }
Describe the given count.

@param  array|Traversable $rows The target model's existing rows.
@throws InvalidArgumentException If the given argument is not iterable.
@return boolean
Describe the given count .