original_string: public function create_cache(cache_definition $definition) {
          $class = $definition->get_cache_class();
          $stores = cache_helper::get_stores_suitable_for_definition($definition);
          foreach ($stores as $key => $store) {
              if (!$store::are_requirements_met()) {
                  unset($stores[$key]);
              }
          }
          if (count($stores) === 0) {
              // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
              $stores[] = $this->create_dummy_store($definition);
          }
          $loader = null;
          if ($definition->has_data_source()) {
              $loader = $definition->get_data_source();
          }
          while (($store = array_pop($stores)) !== null) {
              $loader = new $class($definition, $store, $loader);
          }
          return $loader;
      }
code: public function create_cache(cache_definition $definition) {
          $class = $definition->get_cache_class();
          $stores = cache_helper::get_stores_suitable_for_definition($definition);
          foreach ($stores as $key => $store) {
              if (!$store::are_requirements_met()) {
                  unset($stores[$key]);
              }
          }
          if (count($stores) === 0) {
              // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
              $stores[] = $this->create_dummy_store($definition);
          }
          $loader = null;
          if ($definition->has_data_source()) {
              $loader = $definition->get_data_source();
          }
          while (($store = array_pop($stores)) !== null) {
              $loader = new $class($definition, $store, $loader);
          }
          return $loader;
      }
code_tokens: public function create_cache ( cache_definition $ definition ) { $ class = $ definition -> get_cache_class ( ) ; $ stores = cache_helper :: get_stores_suitable_for_definition ( $ definition ) ; foreach ( $ stores as $ key => $ store ) { if ( ! $ store :: are_requirements_met ( ) ) { unset ( $ stores [ $ key ] ) ; } } if ( count ( $ stores ) === 0 ) { // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser. $ stores [ ] = $ this -> create_dummy_store ( $ definition ) ; } $ loader = null ; if ( $ definition -> has_data_source ( ) ) { $ loader = $ definition -> get_data_source ( ) ; } while ( ( $ store = array_pop ( $ stores ) ) !== null ) { $ loader = new $ class ( $ definition , $ store , $ loader ) ; } return $ loader ; }
docstring: Common public method to create a cache instance given a definition.
  
  This is used by the static make methods.
  
  @param cache_definition $definition
  @return cache_application|cache_session|cache_store
  @throws coding_exception
docstring_tokens: Common public method to create a cache instance given a definition .