<?php
/**
 * Trait UnitsConversionTrait
 *
 * @package DhlPolska\Shipment
 */

namespace DhlPolska\Shipment;

trait UnitsConversionTrait {

	/**
	 * @param float $weight .
	 *
	 * @return float|null
	 */
	private function get_weight_in_kg( float $weight ): ?float {
		if ( $weight <= 0.0 ) {
			return null;
		}

		return (float) wc_get_weight( $weight, 'kg' );
	}

	/**
	 * @param float $dimension .
	 *
	 * @return int|null
	 */
	private function get_dimension_in_cm( float $dimension ): ?int {
		if ( $dimension <= 0.0 ) {
			return null;
		}

		return (int) round( (float) wc_get_dimension( $dimension, 'cm' ) );
	}
}
