Markdown   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 8 1
A renderRaw() 0 5 1
1
<?php
2
namespace FlexyProject\GitHub\Receiver\Miscellaneous;
3
4
use FlexyProject\GitHub\AbstractApi;
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * The Markdown API class lets you render Markdown documents.
9
 *
10
 * @link    https://developer.github.com/v3/markdown/
11
 * @package FlexyProject\GitHub\Receiver\Miscellaneous
12
 */
13
class Markdown extends AbstractMiscellaneous
14
{
15
16
    /**
17
     * Render an arbitrary Markdown document
18
     *
19
     * @link https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
20
     *
21
     * @param string $text    The Markdown text to render
22
     * @param string $mode    The rendering mode.
23
     * @param string $context The repository context. Only taken into account when rendering as gfm
24
     *
25
     * @return array
26
     */
27
    public function render(string $text, string $mode = AbstractApi::MODE_MARKDOWN, string $context = ''): array
28
    {
29
        return $this->getApi()->request('/markdown', Request::METHOD_POST, [
30
            'text'    => $text,
31
            'mode'    => $mode,
32
            'context' => $context
33
        ]);
34
    }
35
36
    /**
37
     * Render a Markdown document in raw mode
38
     *
39
     * @link https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode
40
     *
41
     * @param string $string
42
     *
43
     * @return array
44
     */
45
    public function renderRaw(string $string): array
46
    {
47
        return $this->getApi()->setContentType('text/plain')
48
                    ->request('/markdown/raw', Request::METHOD_POST, ['file' => $string]);
49
    }
50
}