/**
  * throws exceptions if $item is empty
  *
  * this is a wrapper around our IsEmpty check
  *
  * @param  string $itemName
  *         human-readable name of $item
  * @param  mixed $item
  *         the data to check
  * @param  string $exception
  *         the class to use when throwing an exception
  * @return void
  */
 public static function check($itemName, $item, $exception = E4xx_DataCannotBeEmpty::class)
 {
     // robustness!
     RequireStringy::check($itemName);
     // make sure that $item is not empty
     if (IsEmpty::check($item)) {
         throw new $exception($itemName);
     }
 }
 /**
  * extract the first item from a dataset
  *
  * @param  array|Traversable $data
  *         the data to filter
  * @param  mixed $default
  *         the data to return when we cannot filter $data
  * @return mixed
  */
 private static function fromTraversable($data, $default)
 {
     // return the first item available in $data
     //
     // we use a foreach() loop here because it is compatible with
     // both arrays and iterators
     foreach ($data as $item) {
         if (!IsEmpty::check($item)) {
             return $item;
         }
     }
     // if we get here, then $data was empty
     return $default;
 }
 /**
  * @covers ::check
  * @dataProvider provideDataToTest
  */
 public function testCanCallStatically($data, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = IsEmpty::check($data, $expectedResult);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }