public static function fromArray(array $serviceConfiguration)
    {
        if (!isset($serviceConfiguration['class']))
        {
            throw new InvalidServiceException('The service configuration must define a "class" attribute.');
        }

        // construct the service definition
        $defintion = new static($serviceConfiguration['class'], $serviceConfiguration['arguments'] ?? []);

        // add service method calls if configured
        if (isset($serviceConfiguration['calls']))
        {
            foreach($serviceConfiguration['calls'] as $call)
            {
                if (isset($call['method']) && isset($call['arguments']))
                {
                    $defintion->calls($call['method'], $call['arguments']);
                }
                else 
                {
                    throw new InvalidServiceException('Every service call must have the attributes "method" and "arguments".');
                }
            }
        }

        return $defintion;
    }
public static function fromArray(array $serviceConfiguration)
    {
        if (!isset($serviceConfiguration['class']))
        {
            throw new InvalidServiceException('The service configuration must define a "class" attribute.');
        }

        // construct the service definition
        $defintion = new static($serviceConfiguration['class'], $serviceConfiguration['arguments'] ?? []);

        // add service method calls if configured
        if (isset($serviceConfiguration['calls']))
        {
            foreach($serviceConfiguration['calls'] as $call)
            {
                if (isset($call['method']) && isset($call['arguments']))
                {
                    $defintion->calls($call['method'], $call['arguments']);
                }
                else 
                {
                    throw new InvalidServiceException('Every service call must have the attributes "method" and "arguments".');
                }
            }
        }

        return $defintion;
    }
public static function fromArray ( array $ serviceConfiguration ) { if ( ! isset ( $ serviceConfiguration [ 'class' ] ) ) { throw new InvalidServiceException ( 'The service configuration must define a "class" attribute.' ) ; } // construct the service definition $ defintion = new static ( $ serviceConfiguration [ 'class' ] , $ serviceConfiguration [ 'arguments' ] ?? [ ] ) ; // add service method calls if configured if ( isset ( $ serviceConfiguration [ 'calls' ] ) ) { foreach ( $ serviceConfiguration [ 'calls' ] as $ call ) { if ( isset ( $ call [ 'method' ] ) && isset ( $ call [ 'arguments' ] ) ) { $ defintion -> calls ( $ call [ 'method' ] , $ call [ 'arguments' ] ) ; } else { throw new InvalidServiceException ( 'Every service call must have the attributes "method" and "arguments".' ) ; } } } return $ defintion ; }
Construct a single service definition object from an array

ServiceDefinition::fromArray([
'class' => '\Acme\Demo',
'arguments' => ['@foo', ':bar'],
'calls' => [
['method' => 'setName', [':demo.name']]
]
])

@param array             $serviceConfiguration
@return static
Construct a single service definition object from an array