original_string: protected function getSmallestVariant(AttachmentInterface $attachment)
      {
          $smallestKey = null;
          $smallest    = null;
  
          foreach (array_get($attachment->getNormalizedConfig(), 'variants', []) as $variantKey => $variantSteps) {
  
              if ( ! $variantSteps) {
                  continue;
              }
  
              foreach ($variantSteps as $stepKey => $step) {
  
                  if ( ! in_array($stepKey, $this->resizeVariantStepKeys)) {
                      continue;
                  }
  
                  if ( ! preg_match('#(\d+)?x(\d+)?#', array_get($step, 'dimensions', ''), $matches)) {
                      continue;
                  }
  
                  $smallestForVariant = null;
  
                  if ((int) $matches[1] > 0) {
                      $smallestForVariant = (int) $matches[1];
                  }
  
                  if ((int) $matches[2] > 0 && (int) $matches[2] < $smallestForVariant) {
                      $smallestForVariant = (int) $matches[2];
                  }
  
                  if (    null !== $smallestForVariant
                      &&  ($smallestForVariant < $smallest || null === $smallest)
                  ) {
                      $smallestKey = $variantKey;
                      $smallest    = $smallestForVariant;
                  }
  
                  break;
              }
          }
  
          return $smallestKey;
      }
code: protected function getSmallestVariant(AttachmentInterface $attachment)
      {
          $smallestKey = null;
          $smallest    = null;
  
          foreach (array_get($attachment->getNormalizedConfig(), 'variants', []) as $variantKey => $variantSteps) {
  
              if ( ! $variantSteps) {
                  continue;
              }
  
              foreach ($variantSteps as $stepKey => $step) {
  
                  if ( ! in_array($stepKey, $this->resizeVariantStepKeys)) {
                      continue;
                  }
  
                  if ( ! preg_match('#(\d+)?x(\d+)?#', array_get($step, 'dimensions', ''), $matches)) {
                      continue;
                  }
  
                  $smallestForVariant = null;
  
                  if ((int) $matches[1] > 0) {
                      $smallestForVariant = (int) $matches[1];
                  }
  
                  if ((int) $matches[2] > 0 && (int) $matches[2] < $smallestForVariant) {
                      $smallestForVariant = (int) $matches[2];
                  }
  
                  if (    null !== $smallestForVariant
                      &&  ($smallestForVariant < $smallest || null === $smallest)
                  ) {
                      $smallestKey = $variantKey;
                      $smallest    = $smallestForVariant;
                  }
  
                  break;
              }
          }
  
          return $smallestKey;
      }
code_tokens: protected function getSmallestVariant ( AttachmentInterface $ attachment ) { $ smallestKey = null ; $ smallest = null ; foreach ( array_get ( $ attachment -> getNormalizedConfig ( ) , 'variants' , [ ] ) as $ variantKey => $ variantSteps ) { if ( ! $ variantSteps ) { continue ; } foreach ( $ variantSteps as $ stepKey => $ step ) { if ( ! in_array ( $ stepKey , $ this -> resizeVariantStepKeys ) ) { continue ; } if ( ! preg_match ( '#(\d+)?x(\d+)?#' , array_get ( $ step , 'dimensions' , '' ) , $ matches ) ) { continue ; } $ smallestForVariant = null ; if ( ( int ) $ matches [ 1 ] > 0 ) { $ smallestForVariant = ( int ) $ matches [ 1 ] ; } if ( ( int ) $ matches [ 2 ] > 0 && ( int ) $ matches [ 2 ] < $ smallestForVariant ) { $ smallestForVariant = ( int ) $ matches [ 2 ] ; } if ( null !== $ smallestForVariant && ( $ smallestForVariant < $ smallest || null === $ smallest ) ) { $ smallestKey = $ variantKey ; $ smallest = $ smallestForVariant ; } break ; } } return $ smallestKey ; }
docstring: Returns smallest available resize for the attachment.
  
  @param AttachmentInterface $attachment
  @return null|string
docstring_tokens: Returns smallest available resize for the attachment .