original_string: protected function filterByContext($items, $context)
      {
          $filteredItems = [];
          foreach ($items as $categoryName => $category) {
  
              $filteredCategory = [];
              foreach ($category as $item) {
                  $itemContext = is_array($item->context) ? $item->context : [$item->context];
                  if (in_array($context, $itemContext)) {
                      $filteredCategory[] = $item;
                  }
              }
  
              if (count($filteredCategory)) {
                  $filteredItems[$categoryName] = $filteredCategory;
              }
          }
  
          return $filteredItems;
      }
code: protected function filterByContext($items, $context)
      {
          $filteredItems = [];
          foreach ($items as $categoryName => $category) {
  
              $filteredCategory = [];
              foreach ($category as $item) {
                  $itemContext = is_array($item->context) ? $item->context : [$item->context];
                  if (in_array($context, $itemContext)) {
                      $filteredCategory[] = $item;
                  }
              }
  
              if (count($filteredCategory)) {
                  $filteredItems[$categoryName] = $filteredCategory;
              }
          }
  
          return $filteredItems;
      }
code_tokens: protected function filterByContext ( $ items , $ context ) { $ filteredItems = [ ] ; foreach ( $ items as $ categoryName => $ category ) { $ filteredCategory = [ ] ; foreach ( $ category as $ item ) { $ itemContext = is_array ( $ item -> context ) ? $ item -> context : [ $ item -> context ] ; if ( in_array ( $ context , $ itemContext ) ) { $ filteredCategory [ ] = $ item ; } } if ( count ( $ filteredCategory ) ) { $ filteredItems [ $ categoryName ] = $ filteredCategory ; } } return $ filteredItems ; }
docstring: Filters a set of items by a given context.
  @param  array $items
  @param  string $context
  @return array
docstring_tokens: Filters a set of items by a given context .