<commit_before>
package pixeldroid.bdd.reporters
{
    import pixeldroid.bdd.Reporter;
    import pixeldroid.bdd.models.Expectation;
    import pixeldroid.bdd.models.SpecInfo;


    public class ReporterManager implements Reporter
    {
        private var reporters:Vector.<Reporter> = [];


        public function get length():Number
        {
            return reporters.length;
        }


        public function add(reporter:Reporter):void
        {
            if (reporter) reporters.push(reporter);
        }

        public function init(specInfo:SpecInfo):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.init(specInfo);
            }
        }

        public function begin(name:String, total:Number):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.begin(name, total);
            }
        }

        public function report(e:Expectation, durationSec:Number, index:Number, total:Number):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.report(e, durationSec, index, total);
            }
        }<commit_msg>make adding a reporter idempotent; provide a removal function as well<commit_after>
package pixeldroid.bdd.reporters
{
    import pixeldroid.bdd.Reporter;
    import pixeldroid.bdd.models.Expectation;
    import pixeldroid.bdd.models.SpecInfo;


    public class ReporterManager implements Reporter
    {
        private var reporters:Vector.<Reporter> = [];


        public function get length():Number
        {
            return reporters.length;
        }


        public function add(reporter:Reporter):void
        {
            if (reporter && !reporters.contains(reporter)) reporters.push(reporter);
        }

        public function remove(reporter:Reporter):void
        {
            reporters.remove(reporter);
        }

        public function init(specInfo:SpecInfo):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.init(specInfo);
            }
        }

        public function begin(name:String, total:Number):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.begin(name, total);
            }
        }

        public function report(e:Expectation, durationSec:Number, index:Number, total:Number):void
        {
            for each (var reporter:Reporter in reporters)
            {
                reporter.report(e, durationSec, index, total);
            }
        }
{'fraction_non_alphanumeric': 0.08387096774193549, 'fraction_numerical': 0.0, 'mean_word_length': 1.8162393162393162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3743776', 'n_tokens_mistral': 700, 'n_tokens_neox': 664, 'n_words': 149}