original_string: 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;
    }
code: 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;
    }
code_tokens: 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 ; }
docstring: Adjust cost amount for a given carrier
docstring_tokens: Adjust cost amount for a given carrier