mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Implemented tests for AndOperation and optimized Operations
This commit is contained in:
		@@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use App\Entity\Source\AbstractSource;
 | 
			
		||||
use App\Entity\Source\Operation\Attribut\OperandsAttribut;
 | 
			
		||||
use App\Exception\NotProcessedException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -41,7 +42,10 @@ abstract class AbstractOperation extends AbstractSource implements OperandInterf
 | 
			
		||||
 | 
			
		||||
    public function getResult(): ResultInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->result;
 | 
			
		||||
        if ($this->result) {
 | 
			
		||||
            return $this->result;
 | 
			
		||||
        }
 | 
			
		||||
        throw new NotProcessedException('No result was generated!');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setOperators(ArrayCollection $operands): void
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ namespace App\Entity\Source\Operation;
 | 
			
		||||
use App\Logic\Operation\OperandInterface;
 | 
			
		||||
use App\Logic\Result\Result;
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use App\Exception\NotDefinedException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -16,7 +17,7 @@ final class AndOperation extends AbstractOperation
 | 
			
		||||
    public function process(): void
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->operands->isEmpty()) {
 | 
			
		||||
            throw new \Exception('Operands must be defined!');
 | 
			
		||||
            throw new NotDefinedException('Operands must be defined!');
 | 
			
		||||
        }
 | 
			
		||||
        $this->result = new Result();
 | 
			
		||||
        /*
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								application/src/Exception/NotDefinedException.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								application/src/Exception/NotDefinedException.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Exception;
 | 
			
		||||
 | 
			
		||||
class NotDefinedException extends \Exception
 | 
			
		||||
{
 | 
			
		||||
    public function __construct($message = null)
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct($message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								application/src/Exception/NotProcessedException.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								application/src/Exception/NotProcessedException.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Exception;
 | 
			
		||||
 | 
			
		||||
class NotProcessedException extends \Exception
 | 
			
		||||
{
 | 
			
		||||
    public function __construct($message = null)
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct($message);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user