src/Yggdrasil/Utils/Service/AbstractService.php
protected function registerContracts(): void
    {
        $reflection = new \ReflectionClass($this);
        $reader = new AnnotationReader();

        foreach ($reader->getClassAnnotations($reflection) as $annotation) {
            if ($annotation instanceof Drivers) {
                foreach ($annotation->install as $contract => $driver) {
                    $driverInstance = $this->drivers->get($driver);

                    if (!is_subclass_of($driverInstance, $contract)) {
                        throw new BrokenContractException($contract);
                    }

                    $this->{$driver} = $driverInstance;
                }
            }

            if ($annotation instanceof Repository) {
                $repository = $this->drivers->get($annotation->repositoryProvider)->getRepository($annotation->name);

                if (!is_subclass_of($repository, $annotation->contract)) {
                    throw new BrokenContractException($annotation->contract);
                }

                $repositoryReflection = new \ReflectionClass($annotation->contract);
                $property = str_replace('Interface', '', $repositoryReflection->getShortName());

                $this->{lcfirst($property)} = $repository;
            }
        }
    }
protected function registerContracts(): void
    {
        $reflection = new \ReflectionClass($this);
        $reader = new AnnotationReader();

        foreach ($reader->getClassAnnotations($reflection) as $annotation) {
            if ($annotation instanceof Drivers) {
                foreach ($annotation->install as $contract => $driver) {
                    $driverInstance = $this->drivers->get($driver);

                    if (!is_subclass_of($driverInstance, $contract)) {
                        throw new BrokenContractException($contract);
                    }

                    $this->{$driver} = $driverInstance;
                }
            }

            if ($annotation instanceof Repository) {
                $repository = $this->drivers->get($annotation->repositoryProvider)->getRepository($annotation->name);

                if (!is_subclass_of($repository, $annotation->contract)) {
                    throw new BrokenContractException($annotation->contract);
                }

                $repositoryReflection = new \ReflectionClass($annotation->contract);
                $property = str_replace('Interface', '', $repositoryReflection->getShortName());

                $this->{lcfirst($property)} = $repository;
            }
        }
    }
protected function registerContracts ( ) : void { $ reflection = new \ ReflectionClass ( $ this ) ; $ reader = new AnnotationReader ( ) ; foreach ( $ reader -> getClassAnnotations ( $ reflection ) as $ annotation ) { if ( $ annotation instanceof Drivers ) { foreach ( $ annotation -> install as $ contract => $ driver ) { $ driverInstance = $ this -> drivers -> get ( $ driver ) ; if ( ! is_subclass_of ( $ driverInstance , $ contract ) ) { throw new BrokenContractException ( $ contract ) ; } $ this -> { $ driver } = $ driverInstance ; } } if ( $ annotation instanceof Repository ) { $ repository = $ this -> drivers -> get ( $ annotation -> repositoryProvider ) -> getRepository ( $ annotation -> name ) ; if ( ! is_subclass_of ( $ repository , $ annotation -> contract ) ) { throw new BrokenContractException ( $ annotation -> contract ) ; } $ repositoryReflection = new \ ReflectionClass ( $ annotation -> contract ) ; $ property = str_replace ( 'Interface' , '' , $ repositoryReflection -> getShortName ( ) ) ; $ this -> { lcfirst ( $ property ) } = $ repository ; } } }
Registers contracts between service and external suppliers
These contracts may include drivers and repositories and are read from class annotations

@throws BrokenContractException
@throws \ReflectionException
@throws \Doctrine\Common\Annotations\AnnotationException
Registers contracts between service and external suppliers These contracts may include drivers and repositories and are read from class annotations