original_string: public function fit(Size $size, $position = 'center')
      {
          // create size with auto height
          $auto_height = clone $size;
  
          $auto_height->resize($this->width, null, function ($constraint) {
              $constraint->aspectRatio();
          });
  
          // decide which version to use
          if ($auto_height->fitsInto($this)) {
  
              $size = $auto_height;
  
          } else {
  
              // create size with auto width
              $auto_width = clone $size;
  
              $auto_width->resize(null, $this->height, function ($constraint) {
                  $constraint->aspectRatio();
              });
  
              $size = $auto_width;
          }
  
          $this->align($position);
          $size->align($position);
          $size->setPivot($this->relativePosition($size));
  
          return $size;
      }
code: public function fit(Size $size, $position = 'center')
      {
          // create size with auto height
          $auto_height = clone $size;
  
          $auto_height->resize($this->width, null, function ($constraint) {
              $constraint->aspectRatio();
          });
  
          // decide which version to use
          if ($auto_height->fitsInto($this)) {
  
              $size = $auto_height;
  
          } else {
  
              // create size with auto width
              $auto_width = clone $size;
  
              $auto_width->resize(null, $this->height, function ($constraint) {
                  $constraint->aspectRatio();
              });
  
              $size = $auto_width;
          }
  
          $this->align($position);
          $size->align($position);
          $size->setPivot($this->relativePosition($size));
  
          return $size;
      }
code_tokens: public function fit ( Size $ size , $ position = 'center' ) { // create size with auto height $ auto_height = clone $ size ; $ auto_height -> resize ( $ this -> width , null , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; // decide which version to use if ( $ auto_height -> fitsInto ( $ this ) ) { $ size = $ auto_height ; } else { // create size with auto width $ auto_width = clone $ size ; $ auto_width -> resize ( null , $ this -> height , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; $ size = $ auto_width ; } $ this -> align ( $ position ) ; $ size -> align ( $ position ) ; $ size -> setPivot ( $ this -> relativePosition ( $ size ) ) ; return $ size ; }
docstring: Resize given Size to best fitting size of current size.
  
  @param  Size   $size
  @return \Intervention\Image\Size
docstring_tokens: Resize given Size to best fitting size of current size .