public function registerDefaultStats($filename)
    {
        // TODO Just register the filename and load the content after?

        if (!file_exists($filename)) {
            throw new Exception(sprintf('File for defaults stats with filename "%s" is not found', $filename));
        }

        try {
            $yaml = Yaml::parse(file_get_contents($filename));
        } catch (ParseException $e) {
            throw new Exception(sprintf('Unable to parse the YAML string: %s', $e->getMessage()));
        }

        if (!isset($yaml['default_stats']) && !is_array($yaml['default_stats'])) {
            throw new Exception(sprintf('The defaults stats file "%s" must have "%s" key as root',
                $filename,
                'default_stats'
            ));
        }

        $this->defaults = new Collection(
            array_merge($this->defaults->toArray(), $yaml['default_stats'])
        );
    }
public function registerDefaultStats($filename)
    {
        // TODO Just register the filename and load the content after?

        if (!file_exists($filename)) {
            throw new Exception(sprintf('File for defaults stats with filename "%s" is not found', $filename));
        }

        try {
            $yaml = Yaml::parse(file_get_contents($filename));
        } catch (ParseException $e) {
            throw new Exception(sprintf('Unable to parse the YAML string: %s', $e->getMessage()));
        }

        if (!isset($yaml['default_stats']) && !is_array($yaml['default_stats'])) {
            throw new Exception(sprintf('The defaults stats file "%s" must have "%s" key as root',
                $filename,
                'default_stats'
            ));
        }

        $this->defaults = new Collection(
            array_merge($this->defaults->toArray(), $yaml['default_stats'])
        );
    }
public function registerDefaultStats ( $ filename ) { // TODO Just register the filename and load the content after? if ( ! file_exists ( $ filename ) ) { throw new Exception ( sprintf ( 'File for defaults stats with filename "%s" is not found' , $ filename ) ) ; } try { $ yaml = Yaml :: parse ( file_get_contents ( $ filename ) ) ; } catch ( ParseException $ e ) { throw new Exception ( sprintf ( 'Unable to parse the YAML string: %s' , $ e -> getMessage ( ) ) ) ; } if ( ! isset ( $ yaml [ 'default_stats' ] ) && ! is_array ( $ yaml [ 'default_stats' ] ) ) { throw new Exception ( sprintf ( 'The defaults stats file "%s" must have "%s" key as root' , $ filename , 'default_stats' ) ) ; } $ this -> defaults = new Collection ( array_merge ( $ this -> defaults -> toArray ( ) , $ yaml [ 'default_stats' ] ) ) ; }
Register a new default stats file.

@param string $filename Name of the file

@throws Subbly\Api\Service\Exception
@throws Subbly\Api\Service\Exception

@api
Register a new default stats file .