DataSift\Storyplayer\PlayerLib\Report_Loader::loadReport PHP Method

loadReport() public method

public loadReport ( $reportName, $constructorArgs = null )
    public function loadReport($reportName, $constructorArgs = null)
    {
        // can we find the class?
        foreach ($this->namespaces as $namespace) {
            // what is the full name of the class (inc namespace) to
            // search for?
            $className = $this->determineReportClassFor($reportName);
            $namespacedClassName = $namespace . "\\" . $className;
            // is there such a class?
            if (class_exists($namespacedClassName)) {
                // yes there is!!
                //
                // create an instance of the class
                $return = new $namespacedClassName($constructorArgs);
                // make sure our new object is an instance of 'Report'
                if (!$return instanceof Report) {
                    throw new E5xx_NotAReportClass($namespacedClassName);
                }
                // return our newly-minted object
                return $return;
            }
        }
        // if we get there, then we cannot find a suitable class in
        // any of the namespaces that we know about
        throw new E4xx_NoSuchReport($reportName);
    }