Skip to content

Private construct #6

Description

@CodersBrothers

Singleton patron permit __construct as protected or private?

And maybe will be good block clone method as

public function __clone()
{
trigger_error("Cant clone ". get_class($this) ." class.", E_USER_ERROR );
}

And solution for serialize:

public function __wakeup()
{
trigger_error("Cant unserialize". get_class($this) ." class.");
}

And instance method

if ( !self::$instance instanceof self) {
self::$instance = new self;
}
return self::$instance;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions