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.

YouTube_UploadTask::defineSettings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Craft;
4
5
/**
6
 * YouTube Upload Task.
7
 *
8
 * Upload video assets to YouTube.
9
 *
10
 * @author    Bob Olde Hampsink <[email protected]>
11
 * @copyright Copyright (c) 2015, Itmundi
12
 * @license   MIT
13
 *
14
 * @link      http://github.com/boboldehampsink
15
 */
16
class YouTube_UploadTask extends BaseTask
17
{
18
    /**
19
     * Define settings.
20
     *
21
     * @return array
22
     */
23
    protected function defineSettings()
24
    {
25
        return array(
26
            'id'     => AttributeType::Number,
27
            'model'  => AttributeType::Mixed,
28
            'assets' => AttributeType::Mixed,
29
            'user'   => AttributeType::Number,
30
        );
31
    }
32
33
    /**
34
     * Return description.
35
     *
36
     * @return string
37
     */
38
    public function getDescription()
39
    {
40
        return Craft::t('YouTube Upload');
41
    }
42
43
    /**
44
     * Return total steps.
45
     *
46
     * @return int
47
     */
48
    public function getTotalSteps()
49
    {
50
        // Get settings
51
        $settings = $this->getSettings();
52
53
        // Take a step for every asset
54
        return count($settings->assets);
55
    }
56
57
    /**
58
     * Run step.
59
     *
60
     * @param int $step
61
     *
62
     * @return string|bool
63
     */
64
    public function runStep($step)
65
    {
66
        // Get settings
67
        $settings = $this->getSettings();
68
69
        // Get element
70
        $element = craft()->elements->getElementById($settings->id);
71
72
        // Get asset
73
        $asset = craft()->assets->getFileById($settings->assets[$step]);
74
75
        // Check if element and asset still exists
76
        if (is_null($element) || is_null($asset)) {
77
            return true;
78
        }
79
80
        // Return process status
81
        return craft()->youTube->process($element, $asset, $settings->model->handle);
82
    }
83
}
84