protected static function valueToOct($value)
    {
        $result = $value;

        // If the value is a string in a form '0777', then extract octal value
        if (is_string($value) && (strpos($value, '0') === 0)) {
            $value = intval($value, 8);
        }

        // If the value is not octal, convert
        if (decoct(octdec($value)) <> $value) {
            $result = base_convert((string) $value, 10, 8);
        }

        return $value;
    }