SproutCMS

This is the code documentation for the SproutCMS project

function instance()

Construct a new instance of a class with a given name

Usage

mixed Sprout::instance ( string $class_name [, string|array $base_class_name ] );

Example

$inst = Sprout::instance($widget_class, 'Sprout\\Widgets\\Widget');

Arguments

  1. string $class_name
    The name of the class
  2. string|array $base_class_name = NULL
    The base class or interface which the class must extend/implement.
           Can be a string for a single check, or an array for multiple checks.
           NULL disables this check.

Exceptions thrown

  • InvalidArgumentException
    If the class does not exist

Return value

  • mixed
    The new instance