<commit_before><?php

namespace CatLab\Charon\Transformers;

use CatLab\Charon\Exceptions\InvalidPropertyException;
use CatLab\Charon\Interfaces\Context;
use CatLab\Charon\Interfaces\Transformer;

/**
 * Class BooleanTransformer
 * @package CatLab\Charon\Transformers
 */
class BooleanTransformer implements Transformer
{
    /**
     * @param $value
     * @param Context $context
     * @return mixed
     * @throws InvalidPropertyException
     */
    public function toResourceValue($value, Context $context)
    {
        return !!$value;
    }

    /**
     * @param $value
     * @param Context $context
     * @return mixed
     */
    public function toEntityValue($value, Context $context)
    {
        return !!$value;
    }
}<commit_msg>BooleanTransformer should not transform null values.<commit_after><?php

namespace CatLab\Charon\Transformers;

use CatLab\Charon\Exceptions\InvalidPropertyException;
use CatLab\Charon\Interfaces\Context;
use CatLab\Charon\Interfaces\Transformer;

/**
 * Class BooleanTransformer
 * @package CatLab\Charon\Transformers
 */
class BooleanTransformer implements Transformer
{
    /**
     * @param $value
     * @param Context $context
     * @return mixed
     * @throws InvalidPropertyException
     */
    public function toResourceValue($value, Context $context)
    {
        if ($value === null) {
            return null;
        }

        return !!$value;
    }

    /**
     * @param $value
     * @param Context $context
     * @return mixed
     */
    public function toEntityValue($value, Context $context)
    {
        if ($value === null) {
            return null;
        }

        return !!$value;
    }
}
{'fraction_non_alphanumeric': 0.10938433950986252, 'fraction_numerical': 0.0, 'mean_word_length': 2.6953642384105962, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5436856', 'n_tokens_mistral': 486, 'n_tokens_neox': 472, 'n_words': 109}