src/Borla/Chikka/Models/Cost.php
public function adjust(Carrier $carrier = null) {
    // If there's carrier
    if ($carrier !== null) {
      // Set carrier
      $this->carrier = $carrier;
    }
    // If there's no carrier
    if ( ! isset($this->carrier)) {
      // Throw error
      throw new MissingCarrier('Carrier is required to adjust cost');
    }
    // Get costs
    $costs = $this->getPossibleCostsPerCarrier()[$this->carrier->network];
    // Loop through costs per carrier
    foreach ($costs as $i=> $cost) {
      // If cost equals
      if ($this->amount == $cost) {
        // Quit
        break;
      }
      // If amount is less than cost
      if ($this->amount < $cost || ! isset($costs[$i + 1])) {
        // Use previous
        $this->amount = $cost;
        // Break
        break;
      }
    }
    // Return self
    return $this;
  }
public function adjust(Carrier $carrier = null) {
    // If there's carrier
    if ($carrier !== null) {
      // Set carrier
      $this->carrier = $carrier;
    }
    // If there's no carrier
    if ( ! isset($this->carrier)) {
      // Throw error
      throw new MissingCarrier('Carrier is required to adjust cost');
    }
    // Get costs
    $costs = $this->getPossibleCostsPerCarrier()[$this->carrier->network];
    // Loop through costs per carrier
    foreach ($costs as $i=> $cost) {
      // If cost equals
      if ($this->amount == $cost) {
        // Quit
        break;
      }
      // If amount is less than cost
      if ($this->amount < $cost || ! isset($costs[$i + 1])) {
        // Use previous
        $this->amount = $cost;
        // Break
        break;
      }
    }
    // Return self
    return $this;
  }
public function adjust ( Carrier $ carrier = null ) { // If there's carrier if ( $ carrier !== null ) { // Set carrier $ this -> carrier = $ carrier ; } // If there's no carrier if ( ! isset ( $ this -> carrier ) ) { // Throw error throw new MissingCarrier ( 'Carrier is required to adjust cost' ) ; } // Get costs $ costs = $ this -> getPossibleCostsPerCarrier ( ) [ $ this -> carrier -> network ] ; // Loop through costs per carrier foreach ( $ costs as $ i => $ cost ) { // If cost equals if ( $ this -> amount == $ cost ) { // Quit break ; } // If amount is less than cost if ( $ this -> amount < $ cost || ! isset ( $ costs [ $ i + 1 ] ) ) { // Use previous $ this -> amount = $ cost ; // Break break ; } } // Return self return $ this ; }
Adjust cost amount for a given carrier
Adjust cost amount for a given carrier