const cacheToCss = require('./cache-to-css');
const cacheToStylesheets = require('./cache-to-stylesheets');
const generateHtmlString = require('./generate-html-string');
const StyletronCore = require('styletron-core');

/**
 * StyletronServer
 * @packagename styletron-server
 * @extends StyletronCore
 */
class StyletronServer extends StyletronCore {
  /**
   * Create a new StyletronServer instance
   */
  constructor() {
    super();
    this.injectionCount = 0;
  }

  injectDeclaration(decl) {
    this.injectionCount++;
    return super.injectDeclaration(decl);
  }

  getStylesheets() {
    return cacheToStylesheets(this.cache);
  }

  getStylesheetsHtml(className = 'styletron') {
    return generateHtmlString(this.getStylesheets(), className);
  }

  /**
   * Get the CSS string of cache
   * @return {String} The string of CSS
   * @example
   * const styletron = new StyletronServer();
   *
   * styletron.injectDeclaration({prop: 'color', val: 'red'});
   * // → 'c0'
   * styletron.getCss();
   * // → '.c0{color:red}'
   */
  getCss() {
    return cacheToCss(this.cache);
  }

  getInjectionCount() {
    return this.injectionCount;
  }

}

module.exports = StyletronServer;

@@ -446,24 +446,28 @@
 s.injectionC
+allC
 ount = 0;%0A  
@@ -1102,24 +1102,28 @@
 etInjectionC
+allC
 ount() %7B%0A   
@@ -1141,24 +1141,28 @@
 s.injectionC
+allC
 ount;%0A  %7D%0A%0A%7D

rename getInjectionCount to getInjectionCallCount