<commit_before><?php
/**
 * AbstractSection
 *
 * @package   brightnucleus/chainmail
 * @author    <NAME> <<EMAIL>>
 * @license   GPL-2.0+
 * @link      http://www.brightnucleus.com/
 * @copyright 2016 <NAME>, Bright Nucleus
 */

namespace BrightNucleus\ChainMail\Section;

use RuntimeException;
use BrightNucleus\ChainMail\SectionInterface;
use BrightNucleus\ChainMail\Support\ConfigInterface;
use BrightNucleus\ChainMail\Support\Factory;

/**
 * Abstract Class AbstractSection
 *
 * @since   1.0.0
 *
 * @package BrightNucleus\ChainMail
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractSection implements SectionInterface
{

    /**
     * Name of the Section.
     *
     * @since 1.0.0
     *
     * @var string
     */
    protected $sectionName;

    /**
     * Configuration Settings.
     *
     * @since 1.0.0
     *
     * @var ConfigInterface
     */
    protected $config;

    /**
     * Content of the section.
     *
     * @since 1.0.0
     *
     * @var string
     */
    protected $content;

    /**
     * Instantiate a AbstractSection object.
     *
     * @since 1.0.0
     *
     * @param ConfigInterface $config       Configuration settings.
     * @param array           $arguments    Arguments that are passed through
     *                                      the constructor. Contained
     *                                      elements: string $section, string
     *                                      $content
     * @throws RuntimeException
     */
    public function __construct($config, $arguments)
    {
        $this->config = $config;
        list($section, $content) = $arguments;
        $this->setSectionName($section);
        $this->content = $content;
    }

    /**
     * Set the name of the Section.
     *
     * @since 1.0.0
     *
     * @param string $section Optional. Name of the section.
     * @throws RuntimeException
     */
    protected function setSectionName($section = null)
    {
        if (null === $section) {
            throw new RuntimeException('Initialised section without passing it a section name.');
        }
        if ( ! array_key_exists($section, $this->config['sections'])) {
            throw new RuntimeException('Initialised section with an unknown section name.');
        }
        $this->sectionName = $section;
    }
<commit_msg>Return type for `AbstractSection::setSectionName()` should be `string|null`. Resolves #8<commit_after><?php
/**
 * AbstractSection
 *
 * @package   brightnucleus/chainmail
 * @author    <NAME> <<EMAIL>>
 * @license   GPL-2.0+
 * @link      http://www.brightnucleus.com/
 * @copyright 2016 <NAME>, Bright Nucleus
 */

namespace BrightNucleus\ChainMail\Section;

use RuntimeException;
use BrightNucleus\ChainMail\SectionInterface;
use BrightNucleus\ChainMail\Support\ConfigInterface;
use BrightNucleus\ChainMail\Support\Factory;

/**
 * Abstract Class AbstractSection
 *
 * @since   1.0.0
 *
 * @package BrightNucleus\ChainMail
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractSection implements SectionInterface
{

    /**
     * Name of the Section.
     *
     * @since 1.0.0
     *
     * @var string
     */
    protected $sectionName;

    /**
     * Configuration Settings.
     *
     * @since 1.0.0
     *
     * @var ConfigInterface
     */
    protected $config;

    /**
     * Content of the section.
     *
     * @since 1.0.0
     *
     * @var string
     */
    protected $content;

    /**
     * Instantiate a AbstractSection object.
     *
     * @since 1.0.0
     *
     * @param ConfigInterface $config       Configuration settings.
     * @param array           $arguments    Arguments that are passed through
     *                                      the constructor. Contained
     *                                      elements: string $section, string
     *                                      $content
     * @throws RuntimeException
     */
    public function __construct($config, $arguments)
    {
        $this->config = $config;
        list($section, $content) = $arguments;
        $this->setSectionName($section);
        $this->content = $content;
    }

    /**
     * Set the name of the Section.
     *
     * @since 1.0.0
     *
     * @param string|null $section Optional. Name of the section.
     * @throws RuntimeException
     */
    protected function setSectionName($section = null)
    {
        if (null === $section) {
            throw new RuntimeException('Initialised section without passing it a section name.');
        }
        if ( ! array_key_exists($section, $this->config['sections'])) {
            throw new RuntimeException('Initialised section with an unknown section name.');
        }
        $this->sectionName = $section;
    }

{'fraction_non_alphanumeric': 0.11359797297297297, 'fraction_numerical': 0.010346283783783784, 'mean_word_length': 1.960625, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6623106', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1301, 'n_words': 326}