@param array $legend

@throws RuntimeException
541282
public function writeLegend( array $legend ) : void
	{
		$legendStrings = [];
		foreach ( $legend as $status => $output )
		{
			$legendStrings[] = "{$output} {$status}";
		}

		$this->write( "%s\n\n", implode( ' | ', $legendStrings ) );
	}
105065
public function setTokens(array $tokens)
    {
        if (count($tokens) > self::MULTICAST_MAX_TOKENS) {
            throw new \RuntimeException(sprintf('Too many tokens in the list. %s tokens max.', self::MULTICAST_MAX_TOKENS));
        }

        return parent::setTokens($tokens);
    }
982943
public function useLegend(LegendInterface $legend)
    {
        if ($this->legend) {
            $this->finishLegend();
        }

        $event = new UseLegendEvent($legend, $this);
        $this->dispatchEvent($event);
        $this->legend = $legend;

        return $this;
    }
696836
public function setTheme($theme)
    {
        if (!self::isValidTheme($theme)) {
            throw new Exception(
                'Theme ' . $theme . ' is not valid. Please use one of [' . join(', ', self::$themes) . ']'
            );
        }

        $this->theme = $theme;
    }
864593
public function setLayout($template) {
		$layout = $this->getTemplatePathname($template);
		if(!is_file($layout)) {
			throw new \RuntimeException("Layout file `$template` does not exist.");
		} else {
			$this->layout = $template;
		}
	}
402189
public function addResource(string $file): void
    {
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->processData(json_decode($contents, true));
    }
881383
public function compile($path = null)
    {
        if ($path) {
            $this->setPath($path);
        }

        if (!is_null($this->cachePath)) {
            if (!is_file($path)) {
                throw new \RuntimeException("File does not exist at path {$path}");
            }

            file_put_contents(
                $this->getCompiledPath($path),
                $this->compileString(file_get_contents($path))
            );
        }
    }
374887
public function transform(array &$samples) : void
    {
        if (!$this->eigenvectors) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        $samples = Matrix::build($samples)
            ->matmul($this->eigenvectors)
            ->asArray();
    }
1003543
public function setDiscriminatorMap(array $map) : void
    {
        if ($this->isFile) {
            throw MappingException::discriminatorNotAllowedForGridFS($this->name);
        }

        $this->subClasses         = [];
        $this->discriminatorMap   = [];
        $this->discriminatorValue = null;

        foreach ($map as $value => $className) {
            $this->discriminatorMap[$value] = $className;
            if ($this->name === $className) {
                $this->discriminatorValue = $value;
            } else {
                if (! class_exists($className)) {
                    throw MappingException::invalidClassInDiscriminatorMap($className, $this->name);
                }
                if (is_subclass_of($className, $this->name)) {
                    $this->subClasses[] = $className;
                }
            }
        }
    }
432623
public function transform(array &$samples) : void
    {
        if ($this->idfs === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        foreach ($samples as &$sample) {
            foreach ($sample as $column => &$feature) {
                if ($feature > 0) {
                    $feature *= $this->idfs[$column];
                }
            }
        }
    }
562146
public function setLegendClassName($legendClassName)
    {
        $event = new SetLegendClassNameEvent($legendClassName, $this);
        $this->dispatchEvent($event);
        $legendClassName = $event->getLegendClassName();

        $this->legendClassName = (string) $legendClassName;
        $this->legendClass     = new \ReflectionClass($this->legendClassName);
        return $this;
    }
399823
public function transform(array &$samples) : void
    {
        if ($this->intervals === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }
        
        $last = end($this->categories);

        foreach ($samples as &$sample) {
            foreach ($this->intervals as $column => $interval) {
                $value = &$sample[$column];

                foreach ($interval as $i => $edge) {
                    if ($value < $edge) {
                        $value = $this->categories[$i];

                        continue 2;
                    }
                }

                $value = $last;
            }
        }
    }
69790
protected function bulkSend(array $documents)
    {
        try {
            $this->client->addDocuments($documents);
        } catch (ExceptionInterface $e) {
            if (!$this->options['ignore_error']) {
                throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e);
            }
        }
    }
289443
public function prepare()
    {
        if (!empty($this->legend)) {
            $this->addChild(new Child('legend', $this->legend));
        }
        switch ($this->container) {
            case 'table':
                foreach ($this->fields as $fields) {
                    $table = new Child('table');
                    foreach ($fields as $field) {
                        $errors = [];
                        if ($field->hasErrors()) {
                            foreach ($field->getErrors() as $error) {
                                $errors[] = (new Child('div', $error))->setAttribute('class', 'error');
                            }
                        }
                        $tr = new Child('tr');
                        if (null !== $field->getLabel()) {
                            $td = new Child('td');
                            $labelFor = $field->getName() . (($field->getNodeName() == 'fieldset') ? '1' : '');
                            $label = new Child('label', $field->getLabel());
                            $label->setAttribute('for', $labelFor);
                            if (null !== $field->getLabelAttributes()) {
                                $label->setAttributes($field->getLabelAttributes());
                            }
                            if ($field->isRequired()) {
                                if ($label->hasAttribute('class')) {
                                    $label->setAttribute('class', $label->getAttribute('class') . ' required');
                                } else {
                                    $label->setAttribute('class', 'required');
                                }
                            }
                            $td->addChild($label);
                            $tr->addChild($td);
                        }
                        $td = new Child('td');
                        if ($field->isErrorPre()) {
                            $td->addChildren($errors);
                        }
                        $td->addChild($field);
                        if (null !== $field->getHint()) {
                            $hint = new Child('span', $field->getHint());
                            if (null !== $field->getHintAttributes()) {
                                $hint->setAttributes($field->getHintAttributes());
                            }
                            $td->addChild($hint);
                        }
                        if (null === $field->getLabel()) {
                            $td->setAttribute('colspan', 2);
                        }
                        if (!$field->isErrorPre()) {
                            $td->addChildren($errors);
                        }
                        $tr->addChild($td);
                        $table->addChild($tr);
                    }
                    $this->addChild($table);
                }
                break;
            case 'div':
            case 'p':
                foreach ($this->fields as $fields) {
                    foreach ($fields as $field) {
                        $errors = [];
                        if ($field->hasErrors()) {
                            foreach ($field->getErrors() as $error) {
                                $errors[] = (new Child('div', $error))->setAttribute('class', 'error');
                            }
                        }
                        $container = new Child($this->container);
                        if (null !== $field->getLabel()) {
                            $labelFor = $field->getName() . (($field->getNodeName() == 'fieldset') ? '1' : '');
                            $label    = new Child('label', $field->getLabel());
                            $label->setAttribute('for', $labelFor);
                            if (null !== $field->getLabelAttributes()) {
                                $label->setAttributes($field->getLabelAttributes());
                            }
                            if ($field->isRequired()) {
                                if ($label->hasAttribute('class')) {
                                    $label->setAttribute('class', $label->getAttribute('class') . ' required');
                                } else {
                                    $label->setAttribute('class', 'required');
                                }
                            }
                            $container->addChild($label);
                        }
                        if ($field->isErrorPre()) {
                            $container->addChildren($errors);
                        }
                        $container->addChild($field);
                        if (null !== $field->getHint()) {
                            $hint = new Child('span', $field->getHint());
                            if (null !== $field->getHintAttributes()) {
                                $hint->setAttributes($field->getHintAttributes());
                            }
                            $container->addChild($hint);
                        }
                        if (!$field->isErrorPre()) {
                            $container->addChildren($errors);
                        }
                        $this->addChild($container);
                    }
                }
                break;
            default:
                foreach ($this->fields as $fields) {
                    $dl = new Child('dl');
                    foreach ($fields as $field) {
                        $errors = [];
                        if ($field->hasErrors()) {
                            foreach ($field->getErrors() as $error) {
                                $errors[] = (new Child('div', $error))->setAttribute('class', 'error');
                            }
                        }
                        if (null !== $field->getLabel()) {
                            $dt = new Child('dt');
                            $labelFor = $field->getName() . (($field->getNodeName() == 'fieldset') ? '1' : '');
                            $label = new Child('label', $field->getLabel());
                            $label->setAttribute('for', $labelFor);
                            if (null !== $field->getLabelAttributes()) {
                                $label->setAttributes($field->getLabelAttributes());
                            }
                            if ($field->isRequired()) {
                                if ($label->hasAttribute('class')) {
                                    $label->setAttribute('class', $label->getAttribute('class') . ' required');
                                } else {
                                    $label->setAttribute('class', 'required');
                                }
                            }
                            $dt->addChild($label);
                            $dl->addChild($dt);
                        }
                        $dd = new Child('dd');
                        if ($field->isErrorPre()) {
                            $dd->addChildren($errors);
                        }
                        $dd->addChild($field);
                        if (null !== $field->getHint()) {
                            $hint = new Child('span', $field->getHint());
                            if (null !== $field->getHintAttributes()) {
                                $hint->setAttributes($field->getHintAttributes());
                            }
                            $dd->addChild($hint);
                        }
                        if (!$field->isErrorPre()) {
                            $dd->addChildren($errors);
                        }
                        $dl->addChild($dd);
                    }
                    $this->addChild($dl);
                }
        }
        return $this;
    }
94423
public function setRunnable($runnable)
    {
        if (self::isRunnableOk($runnable)) {
            $this->runnable = $runnable;
        } else {
            $this->fatalError(Thread::FUNCTION_NOT_CALLABLE);
        }
    }
867215
public function finishPalette(&$palette = null)
    {
        if (!$this->palette) {
            throw new DcGeneralRuntimeException('Palette is missing, please create a palette first');
        }

        if ($this->legend) {
            $this->finishLegend();
        }
        if ($this->condition) {
            $this->finishCondition();
        }

        $event = new FinishPaletteEvent($this->palette, $this);
        $this->dispatchEvent($event);
        $palette = $event->getPalette();

        if ($this->paletteCollection) {
            $this->paletteCollection->addPalette($palette);
        }

        $this->palette = null;

        return $this;
    }
1210730
private function writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter)
    {
        if (is_null($legend)) {
            return;
        }

        $objWriter->startElement('c:legend');

        $objWriter->startElement('c:legendPos');
        $objWriter->writeAttribute('val', $legend->getPosition());
        $objWriter->endElement();

        $this->writeLayout($legend->getLayout(), $objWriter);

        $objWriter->startElement('c:overlay');
        $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
        $objWriter->endElement();

        $objWriter->startElement('c:txPr');
        $objWriter->startElement('a:bodyPr');
        $objWriter->endElement();

        $objWriter->startElement('a:lstStyle');
        $objWriter->endElement();

        $objWriter->startElement('a:p');
        $objWriter->startElement('a:pPr');
        $objWriter->writeAttribute('rtl', 0);

        $objWriter->startElement('a:defRPr');
        $objWriter->endElement();
        $objWriter->endElement();

        $objWriter->startElement('a:endParaRPr');
        $objWriter->writeAttribute('lang', "en-US");
        $objWriter->endElement();

        $objWriter->endElement();
        $objWriter->endElement();

        $objWriter->endElement();
    }