Completed
Push — master ( e5f058...df872e )
by Benjamin
02:25
created
DataTransformer/EntityToIdTransformer.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@
 block discarded – undo
50 50
             return $this->transformSingleEntity($data);
51 51
         }
52 52
 
53
-        if (is_array($data))
54
-            return $data;
53
+        if (is_array($data)) {
54
+                    return $data;
55
+        }
55 56
 
56 57
         $return = [];
57 58
         $data = explode('#&#', $data);
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -21,6 +21,10 @@
 block discarded – undo
21 21
     private $class;
22 22
     private $multiple;
23 23
 
24
+    /**
25
+     * @param string $class
26
+     * @param string $property
27
+     */
24 28
     public function __construct(EntityManager $em, $class, $property, $queryBuilder, $multiple)
25 29
     {
26 30
         if (!(null === $queryBuilder || $queryBuilder instanceof QueryBuilder || $queryBuilder instanceof \Closure)) {
Please login to merge, or discard this patch.
DependencyInjection/AlpixelMediaExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public function prepend(ContainerBuilder $container)
34 34
     {
35 35
         $parser = new Parser();
36
-        $config = $parser->parse(file_get_contents(__DIR__ . '/../Resources/config/config.yml'));
36
+        $config = $parser->parse(file_get_contents(__DIR__.'/../Resources/config/config.yml'));
37 37
 
38 38
         foreach ($config as $key => $configuration) {
39 39
             $container->prependExtensionConfig($key, $configuration);
Please login to merge, or discard this patch.
Command/MediaCleanupCommand.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     public function configure()
16 16
     {
17 17
         $this->setName('alpixel:media:cleanup')
18
-             ->setDescription('Cleaning unused media');
18
+                ->setDescription('Cleaning unused media');
19 19
     }
20 20
 
21 21
     public function execute(InputInterface $input, OutputInterface $output)
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
         $container = $this->getContainer();
24 24
 
25 25
         $container->get('doctrine.orm.entity_manager')
26
-                  ->getRepository('AlpixelMediaBundle:Media')
27
-                  ->findExpiredMedias();
26
+                    ->getRepository('AlpixelMediaBundle:Media')
27
+                    ->findExpiredMedias();
28 28
 
29 29
         $medias = $container->get('alpixel_media.manager')->cleanup();
30 30
         $output->writeln(sprintf('%s medias deleted', $medias));
Please login to merge, or discard this patch.
Entity/Media.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
     /**
151 151
      * Sets the value of uri.
152 152
      *
153
-     * @param string $name $uri the uri
154 153
      *
154
+     * @param string $uri
155 155
      * @return self
156 156
      */
157 157
     public function setUri($uri)
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
     /**
175 175
      * Sets the value of secretKey.
176 176
      *
177
-     * @param string $name $secretKey the secret key
178 177
      *
178
+     * @param string $secretKey
179 179
      * @return self
180 180
      */
181 181
     public function setSecretKey($secretKey)
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
     /**
199 199
      * Sets the value of mime.
200 200
      *
201
-     * @param string $name $mime the mime
202 201
      *
202
+     * @param string|null $mime
203 203
      * @return self
204 204
      */
205 205
     public function setMime($mime)
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * Sets the value of lifetime.
224 224
      *
225
-     * @param string $label $lifetime the lifetime
226 225
      *
226
+     * @param null|\DateTime $lifetime
227 227
      * @return self
228 228
      */
229 229
     public function setLifetime($lifetime)
Please login to merge, or discard this patch.
DataFixtures/ORM/MediaProvider.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -88,6 +88,9 @@  discard block
 block discarded – undo
88 88
         return $url;
89 89
     }
90 90
 
91
+    /**
92
+     * @param string $url
93
+     */
91 94
     protected function downloadMedia($url, $ext)
92 95
     {
93 96
         $filepath = sys_get_temp_dir() . '/' . uniqid() . '.' . $ext;
@@ -102,6 +105,9 @@  discard block
 block discarded – undo
102 105
         return new File($filepath, 'random');
103 106
     }
104 107
 
108
+    /**
109
+     * @param string $key
110
+     */
105 111
     protected function fetchFromCache($key)
106 112
     {
107 113
         $fs = new Filesystem();
@@ -130,6 +136,9 @@  discard block
 block discarded – undo
130 136
         }
131 137
     }
132 138
 
139
+    /**
140
+     * @param string $key
141
+     */
133 142
     protected function storeInCache($key, File $file)
134 143
     {
135 144
         $fs = new Filesystem();
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     {
29 29
         do {
30 30
             $dimensions = $this->fetchDimensions($width, $height);
31
-            $file = $this->fetchFromCache($dimensions['w'] . '-' . $dimensions['h']);
31
+            $file = $this->fetchFromCache($dimensions['w'].'-'.$dimensions['h']);
32 32
             if ($file === null) {
33 33
                 $file = $this->downloadMedia($this->generateUrl($dimensions, $type), 'jpg');
34
-                $this->storeInCache($dimensions['w'] . '-' . $dimensions['h'], $file);
34
+                $this->storeInCache($dimensions['w'].'-'.$dimensions['h'], $file);
35 35
             }
36 36
         } while (!preg_match('@^image/@', $file->getMimeType()));
37 37
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function randomFile($fileType)
44 44
     {
45
-        $file = $this->fetchFromCache("file-" . $fileType);
45
+        $file = $this->fetchFromCache("file-".$fileType);
46 46
         if ($file === null) {
47 47
             switch ($fileType) {
48 48
                 case "pdf":
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                     break;
52 52
             }
53 53
         }
54
-        $this->storeInCache("file-" . $fileType, $file);
54
+        $this->storeInCache("file-".$fileType, $file);
55 55
         $media = $this->mediaManager->upload($file);
56 56
 
57 57
         return $media;
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
             $url .= 'g/';
82 82
         }
83 83
 
84
-        $url .= $dimensions['w'] . '/' . $dimensions['h'];
84
+        $url .= $dimensions['w'].'/'.$dimensions['h'];
85 85
 
86 86
         $category = ['abstract', 'city', 'nature', 'moutains'];
87
-        $url .= '/' . $category[array_rand($category, 1)] . '/';
87
+        $url .= '/'.$category[array_rand($category, 1)].'/';
88 88
 
89 89
         return $url;
90 90
     }
91 91
 
92 92
     protected function downloadMedia($url, $ext)
93 93
     {
94
-        $filepath = sys_get_temp_dir() . '/' . uniqid() . '.' . $ext;
94
+        $filepath = sys_get_temp_dir().'/'.uniqid().'.'.$ext;
95 95
         $ch = curl_init($url);
96 96
         $fp = fopen($filepath, 'wb');
97 97
         curl_setopt($ch, CURLOPT_FILE, $fp);
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
     protected function fetchFromCache($key)
107 107
     {
108 108
         $fs = new Filesystem();
109
-        $cacheDir = $_SERVER['HOME'] . '/.symfony/media';
109
+        $cacheDir = $_SERVER['HOME'].'/.symfony/media';
110 110
         if (!$fs->exists($cacheDir)) {
111 111
             $fs->mkdir($cacheDir, 0777);
112 112
         } else {
113
-            $cacheDir .= '/' . $key;
113
+            $cacheDir .= '/'.$key;
114 114
             if (!$fs->exists($cacheDir)) {
115 115
                 $fs->mkdir($cacheDir, 0777);
116 116
             } else {
117 117
                 $finder = new Finder();
118
-                $files = $finder->in($cacheDir . '/')->files();
118
+                $files = $finder->in($cacheDir.'/')->files();
119 119
                 if (strrpos($key, "file-") !== false || $files->count() === 3) {
120 120
                     try {
121 121
                         $iterator = $finder->getIterator();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
                             $iterator->next();
125 125
                         }
126 126
                         $file = new File($iterator->current());
127
-                        $fs->copy($file->getRealPath(), sys_get_temp_dir() . '/' . $file->getFilename());
127
+                        $fs->copy($file->getRealPath(), sys_get_temp_dir().'/'.$file->getFilename());
128 128
 
129
-                        return new File(sys_get_temp_dir() . '/' . $file->getFilename());
130
-                    } catch(FileNotFoundException $e) {}
129
+                        return new File(sys_get_temp_dir().'/'.$file->getFilename());
130
+                    } catch (FileNotFoundException $e) {}
131 131
                 }
132 132
             }
133 133
         }
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
     protected function storeInCache($key, File $file)
137 137
     {
138 138
         $fs = new Filesystem();
139
-        $cacheDir = $_SERVER['HOME'] . '/.symfony/media/' . $key;
139
+        $cacheDir = $_SERVER['HOME'].'/.symfony/media/'.$key;
140 140
         if (!$fs->exists($cacheDir)) {
141 141
             $fs->mkdir($cacheDir, 0777);
142 142
         }
143
-        $fs->copy($file->getRealPath(), $cacheDir . '/' . $file->getFilename());
143
+        $fs->copy($file->getRealPath(), $cacheDir.'/'.$file->getFilename());
144 144
     }
145 145
 }
Please login to merge, or discard this patch.
Twig/Extension/MediaPreviewExtension.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -63,6 +63,9 @@
 block discarded – undo
63 63
         return (array_key_exists($mime, $this->previewIcon)) ? $this->previewIcon[$mime] : $this->previewIcon['unknown'];
64 64
     }
65 65
 
66
+    /**
67
+     * @param boolean $isIcon
68
+     */
66 69
     protected function generatePath($isIcon, $str)
67 70
     {
68 71
         if ($isIcon === true) {
Please login to merge, or discard this patch.