import sublime_plugin
from php_coverage.finder import CoverageFinder


class CoverageCommand(sublime_plugin.TextCommand):

    """
    Base class for a text command which has a coverage file.
    """

    def __init__(self, view, coverage_finder=None):
        super(CoverageCommand, self).__init__(view)
        self.coverage_finder = coverage_finder

    def get_coverage_finder(self):
        """
        Gets the coverage finder for the command. If none is set, it
        instantiates an instance of the default CoverageFinder class.
        """
        if not self.coverage_finder:
            self.coverage_finder = CoverageFinder()

        return self.coverage_finder

    def coverage(self):
        """
        Finds the coverage file which contains coverage data for the
        file open in the view which is running this command.
        """
        return self.get_coverage_finder().find(self.view.file_name())

@@ -14,16 +14,67 @@
 e_plugin
+%0A%0Afrom php_coverage.data import CoverageDataFactory
 %0Afrom ph
@@ -770,45 +770,12 @@
     
-Finds the coverage file which contain
+Load
 s co
@@ -793,24 +793,16 @@
  for the
-%0A       
  file op
@@ -824,16 +824,24 @@
 which is
+%0A       
  running
@@ -879,66 +879,216 @@
     
-return self.get_coverage_finder().find(self.view.file_name())
+filename = self.view.file_name()%0A        coverage_file = self.get_coverage_finder().find(filename)%0A        if (coverage_file):%0A            return CoverageDataFactory().factory(coverage_file)%0A%0A        return None
 %0A

Return coverage data in CoverageCommand::coverage()