Page MenuHomeDevCentral

ItemGroupMapping.php
No OneTemporary

ItemGroupMapping.php

<?php
namespace Nasqueron\Notifications\Analyzers;
use Illuminate\Support\Str;
/**
* Map items (repositories, projects, items, etc.) names to groups
*/
class ItemGroupMapping {
///
/// Properties
///
/**
* The group the mapped items belong to
*
* @var string
*/
public $group;
/**
* An array of the items to map, each item a string with the name of the
* repository, project or item used for mapping.
* The wildcard '*' is allowed to specify several items.
*
* @var array
*/
public $items = [];
///
/// Helper methods
///
/**
* Determines if the specified item matches a pattern.
*
* @param string $pattern The pattern, with * allowed as wildcard character
* @param string $item The item name to compare with the pattern
* @return bool
*/
public static function doesItemMatch (
string $pattern,
string $item
) : bool {
return Str::is($pattern, $item);
}
/**
* Determines if the specified item belong to this mapping
*/
public function doesItemBelong (string $actualItem) : bool {
foreach ($this->items as $candidateItem) {
if (static::doesItemMatch($candidateItem, $actualItem)) {
return true;
}
}
return false;
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Sep 12, 20:42 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2978313
Default Alt Text
ItemGroupMapping.php (1 KB)

Event Timeline