public static function fromAggregateRoot($eventSourcedAggregateRoot): AggregateType
    {
        if (! \is_object($eventSourcedAggregateRoot)) {
            throw new Exception\AggregateTypeException(
                \sprintf('Aggregate root must be an object but type of %s given', \gettype($eventSourcedAggregateRoot))
            );
        }

        if ($eventSourcedAggregateRoot instanceof AggregateTypeProvider) {
            return $eventSourcedAggregateRoot->aggregateType();
        }

        $self = new static();
        $self->aggregateType = \get_class($eventSourcedAggregateRoot);

        return $self;
    }
public static function fromAggregateRoot($eventSourcedAggregateRoot): AggregateType
    {
        if (! \is_object($eventSourcedAggregateRoot)) {
            throw new Exception\AggregateTypeException(
                \sprintf('Aggregate root must be an object but type of %s given', \gettype($eventSourcedAggregateRoot))
            );
        }

        if ($eventSourcedAggregateRoot instanceof AggregateTypeProvider) {
            return $eventSourcedAggregateRoot->aggregateType();
        }

        $self = new static();
        $self->aggregateType = \get_class($eventSourcedAggregateRoot);

        return $self;
    }
public static function fromAggregateRoot ( $ eventSourcedAggregateRoot ) : AggregateType { if ( ! \ is_object ( $ eventSourcedAggregateRoot ) ) { throw new Exception \ AggregateTypeException ( \ sprintf ( 'Aggregate root must be an object but type of %s given' , \ gettype ( $ eventSourcedAggregateRoot ) ) ) ; } if ( $ eventSourcedAggregateRoot instanceof AggregateTypeProvider ) { return $ eventSourcedAggregateRoot -> aggregateType ( ) ; } $ self = new static ( ) ; $ self -> aggregateType = \ get_class ( $ eventSourcedAggregateRoot ) ; return $ self ; }
Use this factory when aggregate type should be detected based on given aggregate root

@param object $eventSourcedAggregateRoot

@throws Exception\AggregateTypeException
Use this factory when aggregate type should be detected based on given aggregate root