PHP Class Nwidart\Modules\Support\Stub

Show file Open project: nwidart/laravel-modules Class Usage Examples

Protected Properties

Property Type Description
$basePath null | string The base path of stub file.
$path string The stub path.
$replaces array The replacements array.

Public Methods

Method Description
__construct ( string $path, array $replaces = [] ) The contructor.
__toString ( ) : string Handle magic method __toString.
create ( string $path, array $replaces = [] ) : self Create new self instance.
createFromPath ( string $path, array $replaces = [] ) : self Create new self instance from full path.
getBasePath ( ) : string | null Get base path.
getContents ( ) : mixed | string Get stub contents.
getPath ( ) : string Get stub path.
getReplaces ( ) : array Get replacements.
render ( ) : string Get stub contents.
replace ( array $replaces = [] ) Set replacements array.
saveTo ( string $path, string $filename ) : boolean Save stub to specific path.
setBasePath ( string $path ) Set base path.
setPath ( string $path ) : self Set stub path.

Method Details

__construct() public method

The contructor.
public __construct ( string $path, array $replaces = [] )
$path string
$replaces array

__toString() public method

Handle magic method __toString.
public __toString ( ) : string
return string

create() public static method

Create new self instance.
public static create ( string $path, array $replaces = [] ) : self
$path string
$replaces array
return self

createFromPath() public static method

Create new self instance from full path.
public static createFromPath ( string $path, array $replaces = [] ) : self
$path string
$replaces array
return self

getBasePath() public static method

Get base path.
public static getBasePath ( ) : string | null
return string | null

getContents() public method

Get stub contents.
public getContents ( ) : mixed | string
return mixed | string

getPath() public method

Get stub path.
public getPath ( ) : string
return string

getReplaces() public method

Get replacements.
public getReplaces ( ) : array
return array

render() public method

Get stub contents.
public render ( ) : string
return string

replace() public method

Set replacements array.
public replace ( array $replaces = [] )
$replaces array

saveTo() public method

Save stub to specific path.
public saveTo ( string $path, string $filename ) : boolean
$path string
$filename string
return boolean

setBasePath() public static method

Set base path.
public static setBasePath ( string $path )
$path string

setPath() public method

Set stub path.
public setPath ( string $path ) : self
$path string
return self

Property Details

$basePath protected static property

The base path of stub file.
protected static null|string $basePath
return null | string

$path protected property

The stub path.
protected string $path
return string

$replaces protected property

The replacements array.
protected array $replaces
return array