diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:45:44 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:45:44 +0200 |
commit | f7fc6fd54a5f750de8144b9b05d5ac173470c70a (patch) | |
tree | 8796fc49df1d9d80c7b8817a54580c98c2f100f5 /src/Support/SingletonTraitWithArguments.php | |
parent | 3983548e7c0f107fa7b7cc3c4c36aa009590b481 (diff) |
Adds Connection wrapper for SSH2
Diffstat (limited to 'src/Support/SingletonTraitWithArguments.php')
-rw-r--r-- | src/Support/SingletonTraitWithArguments.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Support/SingletonTraitWithArguments.php b/src/Support/SingletonTraitWithArguments.php new file mode 100644 index 0000000..2ac0653 --- /dev/null +++ b/src/Support/SingletonTraitWithArguments.php @@ -0,0 +1,25 @@ +<?php + +namespace PHPIAC\Support; + +use PetrKnap\Php\Singleton\SingletonTrait; + +trait SingletonTraitWithArguments +{ + use SingletonTrait; + + /** + * @param mixed ...$arguments + * + * @return self + */ + public static function getInstance(mixed ...$arguments) + { + $self = get_called_class(); + if (! isset(self::$instances[$self])) { + self::$instances[$self] = new $self(...$arguments); + } + + return self::$instances[$self]; + } +} |