| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 24 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 47 | 	public function findRule( array $categories = [] ) : Rule { | ||
| 48 | |||
| 49 | $schemaList = $this->schemaFinder->getSchemaListByType( | ||
| 50 | ImageCaption::SCHEMA_TYPE | ||
| 51 | ); | ||
| 52 | |||
| 53 | $rules = $schemaList->newCompartmentIteratorByKey( | ||
| 54 | 'caption_rules', | ||
| 55 | CompartmentIterator::RULE_COMPARTMENT | ||
| 56 | ); | ||
| 57 | |||
| 58 | $categoryFilter = $this->schemaFilterFactory->newCategoryFilter( | ||
| 59 | $categories | ||
| 60 | ); | ||
| 61 | |||
| 62 | $categoryFilter->filter( $rules ); | ||
| 63 | |||
| 64 | // Use the first "best" matched rule | ||
| 65 | 		foreach ( $categoryFilter->getMatches() as $rule ) { | ||
| 66 | return $rule; | ||
| 67 | } | ||
| 68 | |||
| 69 | return $rules->find( 'default_rule', CompartmentIterator::MATCH_KEY )->current(); | ||
| 70 | } | ||
| 71 | |||
| 73 |