sugared-rim/sami

View on GitHub
src/SamiFactoryAwareTrait.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace SugaredRim\Sami;

/**
 * Setter injection trait for SamiFactory awareness.
 */
trait SamiFactoryAwareTrait
{
    protected $samiFactory;

    public function setSamiFactory(callable $samiFactory = null)
    {
        $this->samiFactory = $samiFactory;
    }

    public function getSamiFactory()
    {
        if ($this->samiFactory === null) {
            $this->samiFactory = new SamiFactory();
        }

        return $this->samiFactory;
    }
}