B
B
BonBon Slick2018-01-27 11:50:51
PHP
BonBon Slick, 2018-01-27 11:50:51

What to do if the package method from vendor is static, but you need to call it dynamically?

https://github.com/Behat/Transliterator/blob/maste...
All its methods are static, but you need to do this:

public function __construct(Transliterator $transliterator
    ) {
        $this->transliterator = $transliterator;
    }

public function()
{
        $slug =  Transliterator::transliterate($string) ;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Taras Fomin, 2018-01-27
@BonBonSlick

Just make a wrapper class like this one and call its methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question