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 — master ( 72699b...b8e5ff )
by
unknown
09:37
created

SClientScript   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 81.58%

Importance

Changes 0
Metric Value
dl 0
loc 92
rs 10
c 0
b 0
f 0
ccs 31
cts 38
cp 0.8158
wmc 13
lcom 2
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 8 1
A unregisterScriptFile() 0 9 2
A onBeforeRenderClientScript() 0 3 1
A prepareScripts() 0 10 1
A prepareMainScript() 0 12 3
A prepareCoreScripts() 0 5 2
A restoreScripts() 0 10 3
1
<?php
2
/**
3
 * @author Nikita Melnikov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package ext.mainscript
8
 */
9
class SClientScript extends CClientScript
10
{
11
  public $coreScriptPosition = self::POS_END;
12
13
  public $defaultScriptFilePosition = self::POS_END;
14
15
  /**
16
   * @param string $output
17
   *
18
   * @return void
19
   */
20 7
  public function render(&$output)
21
  {
22 7
    $this->raiseEvent('onBeforeRenderClientScript', new CEvent($this));
23
24 7
    $this->prepareScripts();
25
26 7
    parent::render($output);
27 7
  }
28
29
  /**
30
   * @param $url
31
   * @param null $position
32
   *
33
   * @return $this
34
   */
35
  public function unregisterScriptFile($url, $position = null)
36
  {
37
    if( $position === null )
38
      $position = $this->defaultScriptFilePosition;
39
40
    unset($this->scriptFiles[$position][$url]);
41
42
    return $this;
43
  }
44
45
  public function onBeforeRenderClientScript(CEvent $event)
46
  {
47
  }
48
49
  /**
50
   * Происходит очистка уже загруженных скриптов,
51
   * для того, чтобы в нужном порядке загрузить список скриптов
52
   * По порядку идут:
53
   *  1) файлы скриптов из ядра Yii
54
   *  2) основной скрипт
55
   *  3) восстанавливаются остальные скрипты
56
   */
57 7
  private function prepareScripts()
58
  {
59
    //Clean total scripts
60 7
    $totalScripts = $this->scriptFiles;
61 7
    $this->scriptFiles = array();
62
63 7
    $this->prepareCoreScripts();
64 7
    $this->prepareMainScript();
65 7
    $this->restoreScripts($totalScripts);
66 7
  }
67
68 7
  private function prepareMainScript()
69
  {
70 7
    foreach(Yii::app()->mainscript->getModel()->getScriptList() as $path)
71
    {
72 7
      $url = Yii::app()->assetManager->publish($path, true);
73
74 7
      $this->registerScriptFile($url);
75
76 7
      if( file_exists($sourceMap = $path.'.map') )
77 7
        Yii::app()->assetManager->publish($sourceMap, true);
78 7
    }
79 7
  }
80
81 7
  private function prepareCoreScripts()
82
  {
83 7
    if( Yii::app()->mainscript->mode === 'frontend' )
84 7
      $this->coreScripts = array();
85 7
  }
86
87
  /**
88
   * @param array $totalScripts
89
   */
90 7
  private function restoreScripts($totalScripts)
91
  {
92 7
    foreach($totalScripts as $position => $scriptList)
93
    {
94 6
      foreach($scriptList as $script)
95
      {
96 6
        $this->registerScriptFile($script, $position);
97 6
      }
98 7
    }
99 7
  }
100
}
101