List an array of objects in a nicely formatted table

@param   mixed   $values
@param   string  $params
@return  string
547175
public static function tb($values, $params = '')
		{
			// source data
			$values = $values instanceof Paginator
				? $values->items()
				: ($values instanceof Arrayable
					? $values->toArray()
					: (array) $values);

			// defend against empty data set
			$empty  = empty($values);

			// pre-convert data
			if (!$empty)
			{
				$values = array_map(function ($value) {
					return $value instanceof Arrayable
						? $value->toArray()
						: (array) $value;
				}, $values);
			}
			else
			{
				$values = [['error' => '...']];
			}

			// parameters
			$params         = urldecode($params);
			$opts           = new Options($params);
			$keys           = array_keys((array) $values[0]);

			// options
			$data =
			[
				'values'    => array_values($values),
				'keys'      => $keys,
				'id'        => $opts->get('id', ''),
				'caption'   => $opts->get('caption'),
				'index'     => $opts->has('index'),
				'class'     => $opts->get('class', ''),
				'type'      => $opts->get('type', 'data'),
				'style'     => $opts->get('style', ''),
				'width'     => $opts->get('width', ''),
				'cols'      => (array) $opts->get('cols'),
				'pre'       => (array) $opts->get('pre'),
				'html'      => (array) $opts->get('html'),
				'icon'      => (array) $opts->get('icon'),
			];

			// populate options
			if($opts->pre === 1)
			{
				$data['class'] .= ' pre';
				$data['pre'] = [];
			}
			if($opts->type !== 'text')
			{
				$data['class'] .= ' table-bordered table-striped data';
			}
			if($opts->width)
			{
				$data['style'] .= ';' . self::getCss($opts->width);
			}
			if($opts->wide)
			{
				$data['style'] .= ';width:100%;';
			}
			if ($opts->keys)
			{
				$keys = array_values(array_filter((array) $opts->keys));
				if (in_array('*', $keys))
				{
					$src    = array_diff($keys, ['*']);
					$diff   = array_diff($data['keys'], $keys);
					$keys   = array_merge($src, $diff);
				}
				$data['keys'] = $keys;
			}
			$data['cols'] = array_pad(array_map(function($value)
			{
				return self::getCss($value);
			}, $data['cols']), count($data['keys']), '');

			// handle empty data set
			if($empty)
			{
				$data['caption']    = 'No data';
				$data['keys']       = ['error'];
				$data['class']      .= ' error ';
			};

			// output table
			return view('sketchpad::html.table', $data);
		}
7515
public function profile($values)
    {
        $profile = [];

        foreach (array_keys($values) as $field) {
            $profile[$field] = '';
        }

        return $profile;
    }
987653
public function toArray($values = []): array
    {
        if (! $values) {
            $values = $this->all();
        }

        $array = [];

        if (is_array($values)) {
            foreach ($values as $key => $value) {
                $array[$key] = is_array($value) ? $this->toArray($value) : $value;

                // Convert Item object instance to an array
                if (is_object($value)) {
                    $array[$key] = [
                        'title'    => $value->title,
                        'url'      => $value->url,
                        'children' => $value->children,
                        'fields'   => $value->fields
                    ];

                    // Use recursion to convert all child elements
                    if ($value->children) {
                        $array[$key]['children'] = $this->toArray($value->children);
                    }
                }
            }
        }

        return $array;
    }
746802
public function bind($values = [])
    {
        if (is_object($values)) {
            $values = get_object_vars($values);
        }

        if (!is_array($values)) {
            throw new \InvalidArgumentException('Please give me array or object');
        }

        foreach ($values as $key => $value) {
            $this->$key = $value;
        }

        return $this;
    }
779770
public function filterValues(array $values = null)
    {
        if (null === $values) {
            $values = $this->getFields();
        }
        foreach ($values as $key => $value) {
            $values[$key] = $this->filterValue($value);
        }
        return $values;
    }
820992
final protected function parameterIds(array $values) : array
    {
        foreach ($values as $key => $value) {
            $values[$key] = Expr::idParam($value);
        }

        return $values;
    }
114990
public function appendValues(array $values)
    {
        $appendValues = [];

        foreach ($values as $value) {
            $appendValues[] = $this->formatValue($value);
        }

        $this->message = $this->message . implode(', ', $appendValues);

        return $this;
    }
915171
public function values($values)
    {
        if(!$values instanceof KDatabaseQuerySelect)
        {
            if (!$this->columns && !is_numeric(key($values))) {
                $this->columns(array_keys($values));
            }

            $this->values[] = array_values($values);
        }
        else $this->values = $values;

        return $this;
    }
263365
public function displayValue( $values )
    {
        if ( is_scalar( $values ) && ! empty( $this->splitter ) )
        {
            $values = explode( $this->splitter, $values );
        }

        $result = '';
        $first  = true;
        $values = (array) $values;

        foreach ( $values as $value )
        {
            if ( $first )
            {
                $first = false;
            }
            else
            {
                $result .= $this->separator;
            }

            $result .= parent::displayValue( $value );
        }

        return $result;
    }
924001
public function filter($values)
    {
        if (is_array($values)) {
            foreach ($values as $key => $value) {
                $values[$key] = $this->filterValue($value);
            }
        }

        return $values;
    }
496500
protected function setValuesList(array $values) {
        $parseValues =  [];
        foreach ($values as $value) {
            $parseValues[] = $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($value));
        }
        return '(' . implode(' ' . $this->getDriverEscaper()->getFieldsSeparator() . ' ' ,  $parseValues) . ')';
    }
266642
public function bindParams($params)
    {
        $bindParams = [''];
        
        foreach ($params as $dbColumnName => $dbColumnValue) {
            $dbColumnValueAry = (!is_array($dbColumnValue)) ? [$dbColumnValue] : $dbColumnValue;
            
            $i = 1;
            foreach ($dbColumnValueAry as $dbColumnValueAryValue) {
                ${$dbColumnName . $i} = $dbColumnValueAryValue;
                
                if (is_numeric($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'i';
                } else if (is_double($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'd';
                } else if (is_string($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else if (is_null($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else {
                    $bindParams[0] .= 'b';
                }
                
                $bindParams[] = &${$dbColumnName . $i};
                $i++;
            }
        }
        
        call_user_func_array([$this->statement, 'bind_param'], $bindParams);
        
        return $this;
    }
28862
protected function parseRow(array $values)
    {
        $output_values = [];

        foreach ($values as $name => $value) {
            $output_values[$name] =
                $this->convertField($name, $value) ;
        }

        return $output_values;
    }
1115586
protected function parameterizeValues(array $values)
    {
        foreach ($values as &$value) {
            $value = $this->parameterize($value);
        }

        return '('.implode(',', $values).')';
    }
886048
private function bindUntypedValues(array $values)
    {
        $params = [];
        $types  = str_repeat('s', count($values));

        foreach ($values as &$v) {
            $params[] =& $v;
        }

        return $this->_stmt->bind_param($types, ...$params);
    }
416977
private function searchValue(array $values = [], array $headers = []) {
    foreach($values as $value) {
      if (!array_key_exists($value, $headers)) {
        continue;
      }

      return $headers[$value];
    }
    
    return null;
  }
617737
public function queryValue($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchColumn();
        $this->statement->closeCursor();

        return $rst;
    }