예제 #1
0
파일: Calculator.php 프로젝트: aRn0D/labs
 /**
  * @param array              $numbers
  * @param OperationInterface $strategy
  *
  * @return array
  */
 public function calculate(array $numbers, OperationInterface $strategy)
 {
     $formatedNumbers = [];
     foreach ($numbers as $number) {
         $formatedNumbers[] = $strategy->apply($number);
     }
     return $formatedNumbers;
 }
예제 #2
0
파일: Batch.php 프로젝트: exeu/apai-io
 /**
  * Adds a single operation.
  * Note that only operations with the same operation name can be added.
  * First operation which is added will be the reference and the instance will let you only add
  * other operations with the same operation name.
  *
  * @param OperationInterface $operation
  *
  * @return void
  */
 public function addOperation(OperationInterface $operation)
 {
     if (null === $this->operationName) {
         $this->operationName = $operation->getName();
     }
     if ($this->operationName !== $operation->getName()) {
         return;
     }
     $this->operations[] = $operation;
 }
예제 #3
0
 public function calculate(OperationInterface $operazione, $num1, $num2)
 {
     $result = $operazione->apply($num1, $num2);
     return $result;
 }
예제 #4
0
 /** {@inheritdoc} */
 public function getType()
 {
     return $this->origin->getType();
 }
예제 #5
0
 /**
  * Add a operation to the service description
  *
  * @param OperationInterface $operation Operation to add
  *
  * @return self
  */
 public function addOperation(OperationInterface $operation)
 {
     $this->operations[$operation->getName()] = $operation->setServiceDescription($this);
     return $this;
 }