Exemplo n.º 1
0
 /**
  * Extracts a ratio from a string in a \d+:\d+ format given a key name.
  *
  * @param  Stream     $stream The stream where to look for the ratio.
  * @param  string     $name   the name of the key.
  * @return null|array An array containing the width and the height, null if not found.
  */
 private function extractRatio(Stream $stream, $name)
 {
     if ($stream->has($name)) {
         $ratio = $stream->get($name);
         if (preg_match('/\\d+:\\d+/', $ratio)) {
             $data = array_filter(explode(':', $ratio), function ($int) {
                 return $int > 0;
             });
             if (2 === count($data)) {
                 return array_map(function ($int) {
                     return (int) $int;
                 }, $data);
             }
         }
     }
     return null;
 }