protected function truncateExports( $keep_the_last = 3 ) {
		// Sort files by modification time
		$files = [];
		foreach ( $this->getFiles() as $filepath ) {
			$files[ $filepath ] = filemtime( $filepath );
		}
		arsort( $files );

		// Group sorted files by format
		// Start with/prioritize pins, to to reduce likelihood of deletion
		$groups = [];
		foreach ( $files as $filepath => $timestamp ) {
			$id = $this->getTinyHash( basename( $filepath ) );
			if ( $this->hasPin( $id ) ) {
				$format = $this->getFormat( $filepath );
				$groups[ $format ][] = $filepath;
				unset( $files[ $filepath ] );
			}
		}
		foreach ( $files as $filepath => $timestamp ) {
			$format = $this->getFormat( $filepath );
			$groups[ $format ][] = $filepath;
		}

		// Delete files in group bigger than $keep_the_last
		foreach ( $groups as $group ) {
			$i = 1;
			foreach ( $group as $filepath ) {
				if ( $i > $keep_the_last ) {
					unlink( $filepath );
				}
				++$i;
			}
		}
	}
protected function truncateExports( $keep_the_last = 3 ) {
		// Sort files by modification time
		$files = [];
		foreach ( $this->getFiles() as $filepath ) {
			$files[ $filepath ] = filemtime( $filepath );
		}
		arsort( $files );

		// Group sorted files by format
		// Start with/prioritize pins, to to reduce likelihood of deletion
		$groups = [];
		foreach ( $files as $filepath => $timestamp ) {
			$id = $this->getTinyHash( basename( $filepath ) );
			if ( $this->hasPin( $id ) ) {
				$format = $this->getFormat( $filepath );
				$groups[ $format ][] = $filepath;
				unset( $files[ $filepath ] );
			}
		}
		foreach ( $files as $filepath => $timestamp ) {
			$format = $this->getFormat( $filepath );
			$groups[ $format ][] = $filepath;
		}

		// Delete files in group bigger than $keep_the_last
		foreach ( $groups as $group ) {
			$i = 1;
			foreach ( $group as $filepath ) {
				if ( $i > $keep_the_last ) {
					unlink( $filepath );
				}
				++$i;
			}
		}
	}
protected function truncateExports ( $ keep_the_last = 3 ) { // Sort files by modification time $ files = [ ] ; foreach ( $ this -> getFiles ( ) as $ filepath ) { $ files [ $ filepath ] = filemtime ( $ filepath ) ; } arsort ( $ files ) ; // Group sorted files by format // Start with/prioritize pins, to to reduce likelihood of deletion $ groups = [ ] ; foreach ( $ files as $ filepath => $ timestamp ) { $ id = $ this -> getTinyHash ( basename ( $ filepath ) ) ; if ( $ this -> hasPin ( $ id ) ) { $ format = $ this -> getFormat ( $ filepath ) ; $ groups [ $ format ] [ ] = $ filepath ; unset ( $ files [ $ filepath ] ) ; } } foreach ( $ files as $ filepath => $ timestamp ) { $ format = $ this -> getFormat ( $ filepath ) ; $ groups [ $ format ] [ ] = $ filepath ; } // Delete files in group bigger than $keep_the_last foreach ( $ groups as $ group ) { $ i = 1 ; foreach ( $ group as $ filepath ) { if ( $ i > $ keep_the_last ) { unlink ( $ filepath ) ; } ++ $ i ; } } }
Keep the last three of each specific export format

@param int $keep_the_last (optional)
Keep the last three of each specific export format