src/Clio/Widgets/Tables/Column.php
public function calculateWidth($data, $markupDefinition = null) {

        // if the width is not calculated, or the data is invalid
        if (($this->calculateWidth === false) || !is_array($data) || (count($data) === 0)) {

            // nothing to do, it is not a calculated width
            return;
        }
        
        // initialize the array of sizes of each string
        $sizes = [];
        
        // reset the width
        $this->width = null;

        // if the header text was specified
        if ($this->headerText) {
            
            // add the length to the array of string lengths
            $sizes[] = strlen($this->headerText);
        }

        // go through and create an array sizes
        for ($i=0; $i<count($data); ++$i) {

            // get the text (make it into a string)
            $text = strval($data[$i]);

            // if the markup definition was sent in
            if ($markupDefinition) {

                // strip out any markup symbols
                $text = $markupDefinition->stripMarkupSymbols($text);
            }

            // add the size of this text to the array of sizes
            $sizes[] = strlen($text);
        }

        // now get the highest value in the array of sizes and add the padding
        $widestText = max($sizes) + $this->rightPadding + $this->leftPadding;

        // if the maximum width is defined and the width hasn't already maxed out
        if ($this->maximumWidth) {

            // check to ensure the text length is less than or equal to the maximum width
            if ($widestText <= $this->maximumWidth) {

                // the width is now the newest text length
                $this->width = $widestText;

            } else {
                // set the width to the maximum width (text will be truncated)
                $this->width = $this->maximumWidth;
            }

        // there is no maximum width
        } else {

            // just set the width to that widest text
            $this->width = $widestText;
        }

    }
public function calculateWidth($data, $markupDefinition = null) {

        // if the width is not calculated, or the data is invalid
        if (($this->calculateWidth === false) || !is_array($data) || (count($data) === 0)) {

            // nothing to do, it is not a calculated width
            return;
        }
        
        // initialize the array of sizes of each string
        $sizes = [];
        
        // reset the width
        $this->width = null;

        // if the header text was specified
        if ($this->headerText) {
            
            // add the length to the array of string lengths
            $sizes[] = strlen($this->headerText);
        }

        // go through and create an array sizes
        for ($i=0; $i<count($data); ++$i) {

            // get the text (make it into a string)
            $text = strval($data[$i]);

            // if the markup definition was sent in
            if ($markupDefinition) {

                // strip out any markup symbols
                $text = $markupDefinition->stripMarkupSymbols($text);
            }

            // add the size of this text to the array of sizes
            $sizes[] = strlen($text);
        }

        // now get the highest value in the array of sizes and add the padding
        $widestText = max($sizes) + $this->rightPadding + $this->leftPadding;

        // if the maximum width is defined and the width hasn't already maxed out
        if ($this->maximumWidth) {

            // check to ensure the text length is less than or equal to the maximum width
            if ($widestText <= $this->maximumWidth) {

                // the width is now the newest text length
                $this->width = $widestText;

            } else {
                // set the width to the maximum width (text will be truncated)
                $this->width = $this->maximumWidth;
            }

        // there is no maximum width
        } else {

            // just set the width to that widest text
            $this->width = $widestText;
        }

    }
Run the data through and make the width as wide as the widest text

@param array $data
@param Definition $markupDefinition