/**
  * @param $expected
  * @return ByteCollection
  */
 private function createCollection($expected)
 {
     $collection = new ByteCollection();
     array_map(function ($unit) use($collection) {
         $collection->add($unit);
     }, $expected);
     return $collection;
 }
Ejemplo n.º 2
0
 /**
  * @param Bytes $bytes
  * @return ByteCollection
  */
 public static function allocateBytes(Bytes $bytes)
 {
     $byteCollection = new ByteCollection();
     while ($bytes->numberOfBytes() !== 0) {
         $largestPossible = self::findLargestUnitOfMeasurementPossible($bytes);
         $byteCollection->add($largestPossible);
         $bytes = $bytes->subtract($largestPossible->bytes());
     }
     return $byteCollection;
 }