Skip to content

Instantly share code, notes, and snippets.

@matt-allan
Created May 24, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-allan/3f6970427dce15b01571eb30ac8440b8 to your computer and use it in GitHub Desktop.
Save matt-allan/3f6970427dce15b01571eb30ac8440b8 to your computer and use it in GitHub Desktop.
<?php
abstract class ServiceProvider implements DefinitionSource
{
/**
* @return array
*/
abstract protected function definitions(): array;
/**
* {@inheritdoc}
*/
public function getDefinition($name): ?Definition
{
static $definitionArray;
if (!$definitionArray) {
$definitionArray = new DefinitionArray($this->definitions());
}
return $definitionArray->getDefinition($name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment