public function applyDefaults($definition)
    {
        if (!is_array($definition) || !isset($definition['component'])) {
            return $definition;
        }

        if (is_callable($definition['component'])) {
            return array_merge($this->callableDefaults, $definition);
        }

        if (!isset($definition['component']['class'])) {
            throw new AppException('Missing required "class" key in component definition');
        }

        $definition = array_merge_recursive($this->classDefaults, $definition);

        array_walk(
            $definition['component']['calls'],
            function (&$call) {
                $call = (array) $call;
            }
        );

        return $definition;
    }