Documentation

Header
in package
uses MessageTrait

Console header class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
5.0.0

Table of Contents

Properties

$indent  : string
$margin  : int|null
$width  : int
$wrap  : int|null

Methods

__construct()  : mixed
Instantiate the header object
header()  : string
Build a header
headerCenter()  : string
Build a center-aligned header
headerLeft()  : string
Build a left-aligned header
headerRight()  : string
Build a right-aligned header
line()  : string
Build a horizontal line rule
buildAlignedMessageLines()  : array<string|int, mixed>
Word-wrap and align a message into padded lines of $size width
calculatePad()  : int
Calculate string pad
resolveSize()  : int|string
Resolve an explicit/auto/null $size against the given wrap/width/margin

Properties

$indent

protected string $indent = ''

$margin

protected int|null $margin = null

$wrap

protected int|null $wrap = null

Methods

__construct()

Instantiate the header object

public __construct([string $indent = '' ][, int|null $wrap = null ][, int $width = 0 ][, int|null $margin = null ]) : mixed
Parameters
$indent : string = ''
$wrap : int|null = null
$width : int = 0
$margin : int|null = null

header()

Build a header

public header(string $string[, string $char = '-' ][, int|string|null $size = null ][, string $align = 'left' ][, bool $newline = true ]) : string
Parameters
$string : string
$char : string = '-'
$size : int|string|null = null
$align : string = 'left'
$newline : bool = true
Return values
string

headerCenter()

Build a center-aligned header

public headerCenter(string $string[, string $char = '-' ][, int|string|null $size = 'auto' ][, bool $newline = true ]) : string
Parameters
$string : string
$char : string = '-'
$size : int|string|null = 'auto'
$newline : bool = true
Return values
string

headerLeft()

Build a left-aligned header

public headerLeft(string $string[, string $char = '-' ][, int|string|null $size = 'auto' ][, bool $newline = true ]) : string
Parameters
$string : string
$char : string = '-'
$size : int|string|null = 'auto'
$newline : bool = true
Return values
string

headerRight()

Build a right-aligned header

public headerRight(string $string[, string $char = '-' ][, int|string|null $size = 'auto' ][, bool $newline = true ]) : string
Parameters
$string : string
$char : string = '-'
$size : int|string|null = 'auto'
$newline : bool = true
Return values
string

line()

Build a horizontal line rule

public line([string $char = '-' ][, int|null $size = null ][, bool $newline = true ]) : string
Parameters
$char : string = '-'
$size : int|null = null
$newline : bool = true
Return values
string

buildAlignedMessageLines()

Word-wrap and align a message into padded lines of $size width

protected buildAlignedMessageLines(string $message, int $size, string $align, int $innerPad) : array<string|int, mixed>
Parameters
$message : string
$size : int
$align : string
$innerPad : int
Return values
array<string|int, mixed>

calculatePad()

Calculate string pad

protected calculatePad(string $string, int $size[, string $align = 'center' ]) : int
Parameters
$string : string
$size : int
$align : string = 'center'
Return values
int

resolveSize()

Resolve an explicit/auto/null $size against the given wrap/width/margin

protected resolveSize(string $text, int|string|null $size, int|null $wrap, int $width, int|null $margin[, int $fallbackPadding = 0 ]) : int|string
Parameters
$text : string
$size : int|string|null
$wrap : int|null
$width : int
$margin : int|null
$fallbackPadding : int = 0
Return values
int|string

        
On this page

Search results