for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/******************************************************************************
* An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
*
* Copyright (c) 2016, 2015 Richard Klees <[email protected]>
* This software is licensed under The MIT License. You should have received
* a copy of the license along with the code.
*/
namespace Lechimp\Dicto\App;
use Lechimp\Dicto\Rule\Ruleset;
use Lechimp\Dicto\Definition\RuleParser;
use Lechimp\Dicto\Definition\ParserException;
class RuleLoader {
/**
* @var RuleParser
protected $parser;
public function __construct(RuleParser $parser) {
$this->parser = $parser;
}
* Load rules from file at given path.
* @param string $rule_file_path
* @throws ParserException if file can't be parsed.
* @return Ruleset
public function load_rules_from($rule_file_path) {
if (!file_exists($rule_file_path)) {
throw new \InvalidArgumentException("$rule_file_path does not exist.");
$content = file_get_contents($rule_file_path);
return $this->parser->parse($content);