GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 8f9f4a...5d20fa )
by Miguel Angel
03:25
created

FootnotesFixPlugin::onItemPostParse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the trefoil application.
4
 *
5
 * (c) Miguel Angel Gabriel <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Trefoil\Plugins\Optional;
11
12
use Easybook\Events\BaseEvent;
13
use Easybook\Events\EasybookEvents;
14
use Easybook\Events\ParseEvent;
15
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
use Trefoil\Plugins\BasePlugin;
17
18
/**
19
 * This plugin fixes footnotes.
20
 *
21
 * @deprecated 
22
 *
23
 * It replaces invalid character ':' in footnotes ids generated by the
24
 * Markdown parser (so epubcheck will not complain).
25
 *
26
 */
27
class FootnotesFixPlugin extends BasePlugin implements EventSubscriberInterface
28
{
29
    /* ********************************************************************************
30
     * Event handlers
31
     * ********************************************************************************
32
     */
33
    public static function getSubscribedEvents()
34
    {
35
        return array(
36
            EasybookEvents::POST_PARSE   => array('onItemPostParse'),
37
            EasybookEvents::POST_PUBLISH => 'onPostPublish'
38
        );
39
    }
40
41
    public function onItemPostParse(ParseEvent $event)
42
    {
43
        $this->init($event);
44
45
        $this->processItem();
46
47
        // reload changed item
48
        $event->setItem($this->item);
49
    }
50
51
    public function onPostPublish(BaseEvent $event)
52
    {
53
        $this->init($event);
54
55
        $this->deprecationNotice();
56
    }
57
58
    /* ********************************************************************************
59
     * Implementation
60
     * ********************************************************************************
61
     */
62
63
    /**
64
     * For a content item to be processed, extract generated footnotes.
65
     */
66
    protected function processItem()
67
    {
68
        $this->fixFootnotes();
69
    }
70
71 View Code Duplication
    protected function fixFootnotes()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73
        $content = $this->item['content'];
74
75
        // fix footnotes ref in text
76
        $content = preg_replace('/id="fnref(\d*):/', 'id="fnref$1-', $content);
77
        $content = str_replace('href="#fn:', 'href="#fn-', $content);
78
        
79
        // fix footnotes
80
        $content = str_replace('id="fn:', 'id="fn-', $content);
81
        $content = preg_replace('/href="#fnref(\d*):/', 'href="#fnref$1-', $content);
82
83
        // fix return sign used
84
        $content = str_replace('&#8617;', '[&crarr;]', $content);
85
        
86
        $this->item['content'] = $content;
87
    }
88
}
89