Completed
Push — master ( 522461...c89cc2 )
by Fabien
02:24
created
Classes/Dimension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
 class Dimension
17 17
 {
18 18
 
19
-    /**
20
-     * @var int
21
-     */
22
-    protected $width = 0;
23
-
24
-    /**
25
-     * @var int
26
-     */
27
-    protected $height = 0;
28
-
29
-    /**
30
-     * @param string $dimension
31
-     */
32
-    public function __construct($dimension)
33
-    {
34
-        $dimensions = GeneralUtility::trimExplode('x', $dimension);
35
-        $this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
-        $this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
-    }
38
-
39
-    /**
40
-     * @return mixed
41
-     */
42
-    public function getWidth()
43
-    {
44
-        return $this->width;
45
-    }
46
-
47
-    /**
48
-     * @return int
49
-     */
50
-    public function getHeight()
51
-    {
52
-        return $this->height;
53
-    }
19
+	/**
20
+	 * @var int
21
+	 */
22
+	protected $width = 0;
23
+
24
+	/**
25
+	 * @var int
26
+	 */
27
+	protected $height = 0;
28
+
29
+	/**
30
+	 * @param string $dimension
31
+	 */
32
+	public function __construct($dimension)
33
+	{
34
+		$dimensions = GeneralUtility::trimExplode('x', $dimension);
35
+		$this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
+		$this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
+	}
38
+
39
+	/**
40
+	 * @return mixed
41
+	 */
42
+	public function getWidth()
43
+	{
44
+		return $this->width;
45
+	}
46
+
47
+	/**
48
+	 * @return int
49
+	 */
50
+	public function getHeight()
51
+	{
52
+		return $this->height;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Classes/FileUpload/Base64File.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     protected $extension;
43 43
 
44 44
     /**
45
-     * @return \Fab\Media\FileUpload\Base64File
45
+     * @return false|null
46 46
      */
47 47
     public function __construct()
48 48
     {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     /**
117 117
      * Get MIME type of file.
118 118
      *
119
-     * @return string|boolean MIME type. eg, text/html, false on error
119
+     * @return string|false MIME type. eg, text/html, false on error
120 120
      */
121 121
     public function getMimeType()
122 122
     {
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -16,117 +16,117 @@
 block discarded – undo
16 16
 class Base64File extends \Fab\Media\FileUpload\UploadedFileAbstract
17 17
 {
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $inputName = 'qqfile';
23
-
24
-    /**
25
-     * @var string
26
-     */
27
-    protected $uploadFolder;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    protected $name;
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    protected $image;
38
-
39
-    /**
40
-     * @var string
41
-     */
42
-    protected $extension;
43
-
44
-    /**
45
-     * @return \Fab\Media\FileUpload\Base64File
46
-     */
47
-    public function __construct()
48
-    {
49
-
50
-        // Processes the encoded image data and returns the decoded image
51
-        $encodedImage = GeneralUtility::_POST($this->inputName);
52
-        if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) {
53
-            $this->extension = $matches[1];
54
-        } else {
55
-            return false;
56
-        }
57
-
58
-        // Remove the mime-type header
59
-        $data = reset(array_reverse(explode('base64,', $encodedImage)));
60
-
61
-        // Use strict mode to prevent characters from outside the base64 range
62
-        $this->image = base64_decode($data, true);
63
-
64
-        if (!$this->image) {
65
-            return false;
66
-        }
67
-
68
-        $this->setName(uniqid() . '.' . $this->extension);
69
-    }
70
-
71
-    /**
72
-     * Save the file to the specified path
73
-     *
74
-     * @throws \Fab\Media\Exception\EmptyPropertyException
75
-     * @return boolean true on success
76
-     */
77
-    public function save()
78
-    {
79
-
80
-        if (is_null($this->uploadFolder)) {
81
-            throw new \Fab\Media\Exception\EmptyPropertyException('Upload folder is not defined', 1362587741);
82
-        }
83
-
84
-        if (is_null($this->name)) {
85
-            throw new \Fab\Media\Exception\EmptyPropertyException('File name is not defined', 1362587742);
86
-        }
87
-
88
-        return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0;
89
-    }
90
-
91
-    /**
92
-     * Get the original file name.
93
-     *
94
-     * @return string
95
-     */
96
-    public function getOriginalName()
97
-    {
98
-        return $this->getName();
99
-    }
100
-
101
-    /**
102
-     * Get the file size
103
-     *
104
-     * @throws \Exception
105
-     * @return integer file-size in byte
106
-     */
107
-    public function getSize()
108
-    {
109
-        if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
110
-            return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
111
-        } else {
112
-            throw new \Exception('Getting content length is not supported.');
113
-        }
114
-    }
115
-
116
-    /**
117
-     * Get MIME type of file.
118
-     *
119
-     * @return string|boolean MIME type. eg, text/html, false on error
120
-     */
121
-    public function getMimeType()
122
-    {
123
-        $this->checkFileExistence();
124
-        if (function_exists('finfo_file')) {
125
-            $fileInfo = new \finfo();
126
-            return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
127
-        } elseif (function_exists('mime_content_type')) {
128
-            return mime_content_type($this->getFileWithAbsolutePath());
129
-        }
130
-        return false;
131
-    }
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $inputName = 'qqfile';
23
+
24
+	/**
25
+	 * @var string
26
+	 */
27
+	protected $uploadFolder;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	protected $name;
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	protected $image;
38
+
39
+	/**
40
+	 * @var string
41
+	 */
42
+	protected $extension;
43
+
44
+	/**
45
+	 * @return \Fab\Media\FileUpload\Base64File
46
+	 */
47
+	public function __construct()
48
+	{
49
+
50
+		// Processes the encoded image data and returns the decoded image
51
+		$encodedImage = GeneralUtility::_POST($this->inputName);
52
+		if (preg_match('/^data:image\/(jpg|jpeg|png)/i', $encodedImage, $matches)) {
53
+			$this->extension = $matches[1];
54
+		} else {
55
+			return false;
56
+		}
57
+
58
+		// Remove the mime-type header
59
+		$data = reset(array_reverse(explode('base64,', $encodedImage)));
60
+
61
+		// Use strict mode to prevent characters from outside the base64 range
62
+		$this->image = base64_decode($data, true);
63
+
64
+		if (!$this->image) {
65
+			return false;
66
+		}
67
+
68
+		$this->setName(uniqid() . '.' . $this->extension);
69
+	}
70
+
71
+	/**
72
+	 * Save the file to the specified path
73
+	 *
74
+	 * @throws \Fab\Media\Exception\EmptyPropertyException
75
+	 * @return boolean true on success
76
+	 */
77
+	public function save()
78
+	{
79
+
80
+		if (is_null($this->uploadFolder)) {
81
+			throw new \Fab\Media\Exception\EmptyPropertyException('Upload folder is not defined', 1362587741);
82
+		}
83
+
84
+		if (is_null($this->name)) {
85
+			throw new \Fab\Media\Exception\EmptyPropertyException('File name is not defined', 1362587742);
86
+		}
87
+
88
+		return file_put_contents($this->getFileWithAbsolutePath(), $this->image) > 0;
89
+	}
90
+
91
+	/**
92
+	 * Get the original file name.
93
+	 *
94
+	 * @return string
95
+	 */
96
+	public function getOriginalName()
97
+	{
98
+		return $this->getName();
99
+	}
100
+
101
+	/**
102
+	 * Get the file size
103
+	 *
104
+	 * @throws \Exception
105
+	 * @return integer file-size in byte
106
+	 */
107
+	public function getSize()
108
+	{
109
+		if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
110
+			return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
111
+		} else {
112
+			throw new \Exception('Getting content length is not supported.');
113
+		}
114
+	}
115
+
116
+	/**
117
+	 * Get MIME type of file.
118
+	 *
119
+	 * @return string|boolean MIME type. eg, text/html, false on error
120
+	 */
121
+	public function getMimeType()
122
+	{
123
+		$this->checkFileExistence();
124
+		if (function_exists('finfo_file')) {
125
+			$fileInfo = new \finfo();
126
+			return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
127
+		} elseif (function_exists('mime_content_type')) {
128
+			return mime_content_type($this->getFileWithAbsolutePath());
129
+		}
130
+		return false;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
             return false;
66 66
         }
67 67
 
68
-        $this->setName(uniqid() . '.' . $this->extension);
68
+        $this->setName(uniqid().'.'.$this->extension);
69 69
     }
70 70
 
71 71
     /**
Please login to merge, or discard this patch.
Classes/FileUpload/StreamedFile.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
     /**
96 96
      * Get MIME type of file.
97 97
      *
98
-     * @return string|boolean MIME type. eg, text/html, false on error
98
+     * @return string|false MIME type. eg, text/html, false on error
99 99
      */
100 100
     public function getMimeType()
101 101
     {
Please login to merge, or discard this patch.
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -18,94 +18,94 @@
 block discarded – undo
18 18
 class StreamedFile extends \Fab\Media\FileUpload\UploadedFileAbstract
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $inputName = 'qqfile';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $uploadFolder;
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name;
35
-
36
-    /**
37
-     * Save the file to the specified path
38
-     *
39
-     * @throws EmptyPropertyException
40
-     * @return boolean true on success
41
-     */
42
-    public function save()
43
-    {
44
-
45
-        if (is_null($this->uploadFolder)) {
46
-            throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
47
-        }
48
-
49
-        if (is_null($this->name)) {
50
-            throw new EmptyPropertyException('File name is not defined', 1361787580);
51
-        }
52
-
53
-        $input = fopen("php://input", "r");
54
-        $temp = tmpfile();
55
-        $realSize = stream_copy_to_stream($input, $temp);
56
-        fclose($input);
57
-
58
-        if ($realSize != $this->getSize()) {
59
-            return false;
60
-        }
61
-
62
-        $target = fopen($this->getFileWithAbsolutePath(), "w");
63
-        fseek($temp, 0, SEEK_SET);
64
-        stream_copy_to_stream($temp, $target);
65
-        fclose($target);
66
-
67
-        return true;
68
-    }
69
-
70
-    /**
71
-     * Get the original file name.
72
-     *
73
-     * @return string
74
-     */
75
-    public function getOriginalName()
76
-    {
77
-        return $_GET[$this->inputName];
78
-    }
79
-
80
-    /**
81
-     * Get the file size
82
-     *
83
-     * @throws \Exception
84
-     * @return integer file-size in byte
85
-     */
86
-    public function getSize()
87
-    {
88
-        if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
89
-            return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
90
-        } else {
91
-            throw new \Exception('Getting content length is not supported.');
92
-        }
93
-    }
94
-
95
-    /**
96
-     * Get MIME type of file.
97
-     *
98
-     * @return string|boolean MIME type. eg, text/html, false on error
99
-     */
100
-    public function getMimeType()
101
-    {
102
-        $this->checkFileExistence();
103
-        if (function_exists('finfo_file')) {
104
-            $fileInfo = new \finfo();
105
-            return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
106
-        } elseif (function_exists('mime_content_type')) {
107
-            return mime_content_type($this->getFileWithAbsolutePath());
108
-        }
109
-        return false;
110
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $inputName = 'qqfile';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $uploadFolder;
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name;
35
+
36
+	/**
37
+	 * Save the file to the specified path
38
+	 *
39
+	 * @throws EmptyPropertyException
40
+	 * @return boolean true on success
41
+	 */
42
+	public function save()
43
+	{
44
+
45
+		if (is_null($this->uploadFolder)) {
46
+			throw new EmptyPropertyException('Upload folder is not defined', 1361787579);
47
+		}
48
+
49
+		if (is_null($this->name)) {
50
+			throw new EmptyPropertyException('File name is not defined', 1361787580);
51
+		}
52
+
53
+		$input = fopen("php://input", "r");
54
+		$temp = tmpfile();
55
+		$realSize = stream_copy_to_stream($input, $temp);
56
+		fclose($input);
57
+
58
+		if ($realSize != $this->getSize()) {
59
+			return false;
60
+		}
61
+
62
+		$target = fopen($this->getFileWithAbsolutePath(), "w");
63
+		fseek($temp, 0, SEEK_SET);
64
+		stream_copy_to_stream($temp, $target);
65
+		fclose($target);
66
+
67
+		return true;
68
+	}
69
+
70
+	/**
71
+	 * Get the original file name.
72
+	 *
73
+	 * @return string
74
+	 */
75
+	public function getOriginalName()
76
+	{
77
+		return $_GET[$this->inputName];
78
+	}
79
+
80
+	/**
81
+	 * Get the file size
82
+	 *
83
+	 * @throws \Exception
84
+	 * @return integer file-size in byte
85
+	 */
86
+	public function getSize()
87
+	{
88
+		if (isset($GLOBALS['_SERVER']['CONTENT_LENGTH'])) {
89
+			return (int)$GLOBALS['_SERVER']['CONTENT_LENGTH'];
90
+		} else {
91
+			throw new \Exception('Getting content length is not supported.');
92
+		}
93
+	}
94
+
95
+	/**
96
+	 * Get MIME type of file.
97
+	 *
98
+	 * @return string|boolean MIME type. eg, text/html, false on error
99
+	 */
100
+	public function getMimeType()
101
+	{
102
+		$this->checkFileExistence();
103
+		if (function_exists('finfo_file')) {
104
+			$fileInfo = new \finfo();
105
+			return $fileInfo->file($this->getFileWithAbsolutePath(), FILEINFO_MIME_TYPE);
106
+		} elseif (function_exists('mime_content_type')) {
107
+			return mime_content_type($this->getFileWithAbsolutePath());
108
+		}
109
+		return false;
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Classes/TypeConverter/FileConverter.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,43 +19,43 @@
 block discarded – undo
19 19
 class FileConverter extends AbstractTypeConverter
20 20
 {
21 21
 
22
-    /**
23
-     * @var array<string>
24
-     */
25
-    protected $sourceTypes = array('int');
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $targetType = 'TYPO3\CMS\Core\Resource\File';
31
-
32
-    /**
33
-     * @var integer
34
-     */
35
-    protected $priority = 1;
36
-
37
-    /**
38
-     * Actually convert from $source to $targetType
39
-     *
40
-     * @param string $source
41
-     * @param string $targetType
42
-     * @param array $convertedChildProperties
43
-     * @param PropertyMappingConfigurationInterface $configuration
44
-     * @return File
45
-     * @api
46
-     */
47
-    public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
48
-    {
49
-
50
-        /** @var $file File */
51
-        $file = ResourceFactory::getInstance()->getFileObject((int)$source);
52
-
53
-        if (!$file) {
54
-            $message = sprintf('File with identifier "%s" could not be found.', $file);
55
-            throw new \Exception($message, 1433529796);
56
-        }
57
-
58
-        $file->getType(); // force to internally know its mime-type.
59
-        return $file;
60
-    }
22
+	/**
23
+	 * @var array<string>
24
+	 */
25
+	protected $sourceTypes = array('int');
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $targetType = 'TYPO3\CMS\Core\Resource\File';
31
+
32
+	/**
33
+	 * @var integer
34
+	 */
35
+	protected $priority = 1;
36
+
37
+	/**
38
+	 * Actually convert from $source to $targetType
39
+	 *
40
+	 * @param string $source
41
+	 * @param string $targetType
42
+	 * @param array $convertedChildProperties
43
+	 * @param PropertyMappingConfigurationInterface $configuration
44
+	 * @return File
45
+	 * @api
46
+	 */
47
+	public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
48
+	{
49
+
50
+		/** @var $file File */
51
+		$file = ResourceFactory::getInstance()->getFileObject((int)$source);
52
+
53
+		if (!$file) {
54
+			$message = sprintf('File with identifier "%s" could not be found.', $file);
55
+			throw new \Exception($message, 1433529796);
56
+		}
57
+
58
+		$file->getType(); // force to internally know its mime-type.
59
+		return $file;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Classes/TypeConverter/ContentToFileConverter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -19,30 +19,30 @@
 block discarded – undo
19 19
 class ContentToFileConverter implements SingletonInterface
20 20
 {
21 21
 
22
-    /**
23
-     * Convert a file representation to File Resource.
24
-     *
25
-     * @param Content|int $fileRepresentation
26
-     * @throws \RuntimeException
27
-     * @return File
28
-     */
29
-    public function convert($fileRepresentation)
30
-    {
31
-
32
-        if ($fileRepresentation instanceof Content) {
33
-
34
-            $fileData = $fileRepresentation->toArray();
35
-            $fileData['modification_date'] = $fileData['tstamp'];
36
-
37
-            if (!isset($fileData['storage']) && $fileData['storage'] === null) {
38
-                throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
39
-            }
40
-
41
-            $fileUid = $fileData['uid'];
42
-        } else {
43
-            $fileData = [];
44
-            $fileUid = (int)$fileRepresentation;
45
-        }
46
-        return ResourceFactory::getInstance()->getFileObject($fileUid, $fileData);
47
-    }
22
+	/**
23
+	 * Convert a file representation to File Resource.
24
+	 *
25
+	 * @param Content|int $fileRepresentation
26
+	 * @throws \RuntimeException
27
+	 * @return File
28
+	 */
29
+	public function convert($fileRepresentation)
30
+	{
31
+
32
+		if ($fileRepresentation instanceof Content) {
33
+
34
+			$fileData = $fileRepresentation->toArray();
35
+			$fileData['modification_date'] = $fileData['tstamp'];
36
+
37
+			if (!isset($fileData['storage']) && $fileData['storage'] === null) {
38
+				throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
39
+			}
40
+
41
+			$fileUid = $fileData['uid'];
42
+		} else {
43
+			$fileData = [];
44
+			$fileUid = (int)$fileRepresentation;
45
+		}
46
+		return ResourceFactory::getInstance()->getFileObject($fileUid, $fileData);
47
+	}
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
Classes/ViewHelpers/ReportToViewHelper.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
16 16
 class ReportToViewHelper extends AbstractViewHelper
17 17
 {
18 18
 
19
-    /**
20
-     * Returns the people who will receive a report.
21
-     *
22
-     * @throws \Exception
23
-     * @return string
24
-     */
25
-    public function render()
26
-    {
27
-        $reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
-        if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
-            $reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
-        }
31
-        return $reportTo;
32
-    }
19
+	/**
20
+	 * Returns the people who will receive a report.
21
+	 *
22
+	 * @throws \Exception
23
+	 * @return string
24
+	 */
25
+	public function render()
26
+	{
27
+		$reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
+		if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
+			$reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
+		}
31
+		return $reportTo;
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/MetadataViewHelper.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -21,50 +21,50 @@
 block discarded – undo
21 21
 class MetadataViewHelper extends AbstractViewHelper
22 22
 {
23 23
 
24
-    /**
25
-     * Returns metadata according to a template.
26
-     *
27
-     * @param File $file
28
-     * @param string $template
29
-     * @param array $metadataProperties
30
-     * @param array $configuration
31
-     * @return string
32
-     */
33
-    public function render(File $file, $template = '', array $metadataProperties = array('size', 'width', 'height'), $configuration = [])
34
-    {
24
+	/**
25
+	 * Returns metadata according to a template.
26
+	 *
27
+	 * @param File $file
28
+	 * @param string $template
29
+	 * @param array $metadataProperties
30
+	 * @param array $configuration
31
+	 * @return string
32
+	 */
33
+	public function render(File $file, $template = '', array $metadataProperties = array('size', 'width', 'height'), $configuration = [])
34
+	{
35 35
 
36
-        if (empty($template)) {
37
-            $template = $this->getDefaultTemplate($file);
38
-        }
36
+		if (empty($template)) {
37
+			$template = $this->getDefaultTemplate($file);
38
+		}
39 39
 
40
-        $result = $template;
41
-        foreach ($metadataProperties as $metadataProperty) {
42
-            $value = $file->getProperty($metadataProperty);
43
-            if ($metadataProperty === 'size') {
44
-                $sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
45
-                $value = round($file->getSize() / $sizeUnit);
46
-            }
47
-            $result = str_replace('%' . $metadataProperty, $value, $result);
48
-        }
40
+		$result = $template;
41
+		foreach ($metadataProperties as $metadataProperty) {
42
+			$value = $file->getProperty($metadataProperty);
43
+			if ($metadataProperty === 'size') {
44
+				$sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
45
+				$value = round($file->getSize() / $sizeUnit);
46
+			}
47
+			$result = str_replace('%' . $metadataProperty, $value, $result);
48
+		}
49 49
 
50
-        return $result;
51
-    }
50
+		return $result;
51
+	}
52 52
 
53
-    /**
54
-     * Returns a default template.
55
-     *
56
-     * @param File $file
57
-     * @return string
58
-     */
59
-    protected function getDefaultTemplate(File $file)
60
-    {
53
+	/**
54
+	 * Returns a default template.
55
+	 *
56
+	 * @param File $file
57
+	 * @return string
58
+	 */
59
+	protected function getDefaultTemplate(File $file)
60
+	{
61 61
 
62
-        $template = '%size KB';
62
+		$template = '%size KB';
63 63
 
64
-        if ($file->getType() == File::FILETYPE_IMAGE) {
65
-            $template = '%width x %height - ' . $template;
66
-        }
64
+		if ($file->getType() == File::FILETYPE_IMAGE) {
65
+			$template = '%width x %height - ' . $template;
66
+		}
67 67
 
68
-        return $template;
69
-    }
68
+		return $template;
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                 $sizeUnit = empty($configuration['sizeUnit']) ? 1000 : $configuration['sizeUnit'];
45 45
                 $value = round($file->getSize() / $sizeUnit);
46 46
             }
47
-            $result = str_replace('%' . $metadataProperty, $value, $result);
47
+            $result = str_replace('%'.$metadataProperty, $value, $result);
48 48
         }
49 49
 
50 50
         return $result;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $template = '%size KB';
63 63
 
64 64
         if ($file->getType() == File::FILETYPE_IMAGE) {
65
-            $template = '%width x %height - ' . $template;
65
+            $template = '%width x %height - '.$template;
66 66
         }
67 67
 
68 68
         return $template;
Please login to merge, or discard this patch.
Classes/Index/TitleMetadataExtractor.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -20,124 +20,124 @@
 block discarded – undo
20 20
 class TitleMetadataExtractor implements ExtractorInterface
21 21
 {
22 22
 
23
-    /**
24
-     * Returns an array of supported file types;
25
-     * An empty array indicates all filetypes
26
-     *
27
-     * @return array
28
-     */
29
-    public function getFileTypeRestrictions()
30
-    {
31
-        return [];
32
-    }
23
+	/**
24
+	 * Returns an array of supported file types;
25
+	 * An empty array indicates all filetypes
26
+	 *
27
+	 * @return array
28
+	 */
29
+	public function getFileTypeRestrictions()
30
+	{
31
+		return [];
32
+	}
33 33
 
34
-    /**
35
-     * Get all supported DriverClasses
36
-     * Since some extractors may only work for local files, and other extractors
37
-     * are especially made for grabbing data from remote.
38
-     * Returns array of string with driver names of Drivers which are supported,
39
-     * If the driver did not register a name, it's the classname.
40
-     * empty array indicates no restrictions
41
-     *
42
-     * @return array
43
-     */
44
-    public function getDriverRestrictions()
45
-    {
46
-        return [];
47
-    }
34
+	/**
35
+	 * Get all supported DriverClasses
36
+	 * Since some extractors may only work for local files, and other extractors
37
+	 * are especially made for grabbing data from remote.
38
+	 * Returns array of string with driver names of Drivers which are supported,
39
+	 * If the driver did not register a name, it's the classname.
40
+	 * empty array indicates no restrictions
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function getDriverRestrictions()
45
+	{
46
+		return [];
47
+	}
48 48
 
49
-    /**
50
-     * Returns the data priority of the extraction Service.
51
-     * Defines the precedence of Data if several extractors
52
-     * extracted the same property.
53
-     * Should be between 1 and 100, 100 is more important than 1
54
-     *
55
-     * @return integer
56
-     */
57
-    public function getPriority()
58
-    {
59
-        return 15;
60
-    }
49
+	/**
50
+	 * Returns the data priority of the extraction Service.
51
+	 * Defines the precedence of Data if several extractors
52
+	 * extracted the same property.
53
+	 * Should be between 1 and 100, 100 is more important than 1
54
+	 *
55
+	 * @return integer
56
+	 */
57
+	public function getPriority()
58
+	{
59
+		return 15;
60
+	}
61 61
 
62
-    /**
63
-     * Returns the execution priority of the extraction Service
64
-     * Should be between 1 and 100, 100 means runs as first service, 1 runs at last service
65
-     *
66
-     * @return integer
67
-     */
68
-    public function getExecutionPriority()
69
-    {
70
-        return 15;
71
-    }
62
+	/**
63
+	 * Returns the execution priority of the extraction Service
64
+	 * Should be between 1 and 100, 100 means runs as first service, 1 runs at last service
65
+	 *
66
+	 * @return integer
67
+	 */
68
+	public function getExecutionPriority()
69
+	{
70
+		return 15;
71
+	}
72 72
 
73
-    /**
74
-     * Checks if the given file can be processed by this Extractor
75
-     *
76
-     * @param File $file
77
-     * @return boolean
78
-     */
79
-    public function canProcess(File $file)
80
-    {
81
-        return true;
82
-    }
73
+	/**
74
+	 * Checks if the given file can be processed by this Extractor
75
+	 *
76
+	 * @param File $file
77
+	 * @return boolean
78
+	 */
79
+	public function canProcess(File $file)
80
+	{
81
+		return true;
82
+	}
83 83
 
84
-    /**
85
-     * The actual processing TASK
86
-     * Should return an array with database properties for sys_file_metadata to write
87
-     *
88
-     * @param File $file
89
-     * @param array $previousExtractedData optional, contains the array of already extracted data
90
-     * @return array
91
-     */
92
-    public function extractMetaData(File $file, array $previousExtractedData = [])
93
-    {
94
-        $metadata = [];
95
-        $title = $file->getProperty('title');
96
-        if (empty($title)) {
97
-            $metadata = array('title' => $this->guessTitle($file->getName()));
98
-        }
99
-        return $metadata;
100
-    }
84
+	/**
85
+	 * The actual processing TASK
86
+	 * Should return an array with database properties for sys_file_metadata to write
87
+	 *
88
+	 * @param File $file
89
+	 * @param array $previousExtractedData optional, contains the array of already extracted data
90
+	 * @return array
91
+	 */
92
+	public function extractMetaData(File $file, array $previousExtractedData = [])
93
+	{
94
+		$metadata = [];
95
+		$title = $file->getProperty('title');
96
+		if (empty($title)) {
97
+			$metadata = array('title' => $this->guessTitle($file->getName()));
98
+		}
99
+		return $metadata;
100
+	}
101 101
 
102
-    /**
103
-     * Guess a title given a file name. Examples:
104
-     * name: my-file-name.jpg -> title: My file name
105
-     * name: myFileName.jpg -> title: My file name
106
-     *
107
-     * @param string $fileName
108
-     * @return string
109
-     */
110
-    protected function guessTitle($fileName)
111
-    {
112
-        $fileNameWithoutExtension = $this->removeExtension($fileName);
102
+	/**
103
+	 * Guess a title given a file name. Examples:
104
+	 * name: my-file-name.jpg -> title: My file name
105
+	 * name: myFileName.jpg -> title: My file name
106
+	 *
107
+	 * @param string $fileName
108
+	 * @return string
109
+	 */
110
+	protected function guessTitle($fileName)
111
+	{
112
+		$fileNameWithoutExtension = $this->removeExtension($fileName);
113 113
 
114
-        $title = $fileNameWithoutExtension;
115
-        // first case: the name is separated by _ or -
116
-        // second case: this is an upper camel case name
117
-        if (preg_match('/-|_/is', $fileNameWithoutExtension)) {
118
-            $title = preg_replace('/-|_/is', ' ', $fileNameWithoutExtension);
119
-        } elseif (preg_match('/[A-Z]/', $fileNameWithoutExtension)) {
120
-            $parts = preg_split('/(?=[A-Z])/', $fileNameWithoutExtension, -1, PREG_SPLIT_NO_EMPTY);
121
-            $title = implode(' ', $parts);
122
-        }
114
+		$title = $fileNameWithoutExtension;
115
+		// first case: the name is separated by _ or -
116
+		// second case: this is an upper camel case name
117
+		if (preg_match('/-|_/is', $fileNameWithoutExtension)) {
118
+			$title = preg_replace('/-|_/is', ' ', $fileNameWithoutExtension);
119
+		} elseif (preg_match('/[A-Z]/', $fileNameWithoutExtension)) {
120
+			$parts = preg_split('/(?=[A-Z])/', $fileNameWithoutExtension, -1, PREG_SPLIT_NO_EMPTY);
121
+			$title = implode(' ', $parts);
122
+		}
123 123
 
124
-        // Remove double space.
125
-        $title = preg_replace('/\s+/', ' ', $title);
126
-        return ucfirst($title);
127
-    }
124
+		// Remove double space.
125
+		$title = preg_replace('/\s+/', ' ', $title);
126
+		return ucfirst($title);
127
+	}
128 128
 
129
-    /**
130
-     * Remove extension of a file.
131
-     *
132
-     * @param string $fileName
133
-     * @return string
134
-     */
135
-    protected function removeExtension($fileName)
136
-    {
137
-        $parts = explode('.', $fileName);
138
-        if (!empty($parts)) {
139
-            array_pop($parts);
140
-        }
141
-        return implode('.', $parts);
142
-    }
129
+	/**
130
+	 * Remove extension of a file.
131
+	 *
132
+	 * @param string $fileName
133
+	 * @return string
134
+	 */
135
+	protected function removeExtension($fileName)
136
+	{
137
+		$parts = explode('.', $fileName);
138
+		if (!empty($parts)) {
139
+			array_pop($parts);
140
+		}
141
+		return implode('.', $parts);
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Classes/FileUpload/ImageOptimizer.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -17,83 +17,83 @@
 block discarded – undo
17 17
 class ImageOptimizer implements SingletonInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $optimizers = [];
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $optimizers = [];
24 24
 
25
-    /**
26
-     * @var \TYPO3\CMS\Core\Resource\ResourceStorage
27
-     */
28
-    protected $storage;
25
+	/**
26
+	 * @var \TYPO3\CMS\Core\Resource\ResourceStorage
27
+	 */
28
+	protected $storage;
29 29
 
30
-    /**
31
-     * Returns a class instance.
32
-     *
33
-     * @return ImageOptimizer
34
-     * @throws \InvalidArgumentException
35
-     * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
36
-     */
37
-    static public function getInstance($storage = null)
38
-    {
39
-        return GeneralUtility::makeInstance(self::class, $storage);
40
-    }
30
+	/**
31
+	 * Returns a class instance.
32
+	 *
33
+	 * @return ImageOptimizer
34
+	 * @throws \InvalidArgumentException
35
+	 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
36
+	 */
37
+	static public function getInstance($storage = null)
38
+	{
39
+		return GeneralUtility::makeInstance(self::class, $storage);
40
+	}
41 41
 
42
-    /**
43
-     * Constructor
44
-     *
45
-     * @return ImageOptimizer
46
-     * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
47
-     */
48
-    public function __construct($storage = null)
49
-    {
50
-        $this->storage = $storage;
51
-        $this->add('Fab\Media\FileUpload\Optimizer\Resize');
52
-        $this->add('Fab\Media\FileUpload\Optimizer\Rotate');
53
-    }
42
+	/**
43
+	 * Constructor
44
+	 *
45
+	 * @return ImageOptimizer
46
+	 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
47
+	 */
48
+	public function __construct($storage = null)
49
+	{
50
+		$this->storage = $storage;
51
+		$this->add('Fab\Media\FileUpload\Optimizer\Resize');
52
+		$this->add('Fab\Media\FileUpload\Optimizer\Rotate');
53
+	}
54 54
 
55
-    /**
56
-     * Register a new optimizer
57
-     *
58
-     * @param string $className
59
-     * @return void
60
-     */
61
-    public function add($className)
62
-    {
63
-        $this->optimizers[] = $className;
64
-    }
55
+	/**
56
+	 * Register a new optimizer
57
+	 *
58
+	 * @param string $className
59
+	 * @return void
60
+	 */
61
+	public function add($className)
62
+	{
63
+		$this->optimizers[] = $className;
64
+	}
65 65
 
66
-    /**
67
-     * Un-register a new optimizer
68
-     *
69
-     * @param string $className
70
-     * @return void
71
-     */
72
-    public function remove($className)
73
-    {
74
-        if (in_array($className, $this->optimizers)) {
75
-            $key = array_search($className, $this->optimizers);
76
-            unset($this->optimizers[$key]);
77
-        }
78
-    }
66
+	/**
67
+	 * Un-register a new optimizer
68
+	 *
69
+	 * @param string $className
70
+	 * @return void
71
+	 */
72
+	public function remove($className)
73
+	{
74
+		if (in_array($className, $this->optimizers)) {
75
+			$key = array_search($className, $this->optimizers);
76
+			unset($this->optimizers[$key]);
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * Optimize an image
82
-     *
83
-     * @param UploadedFileInterface $uploadedFile
84
-     * @return UploadedFileInterface
85
-     * @throws \InvalidArgumentException
86
-     */
87
-    public function optimize(UploadedFileInterface $uploadedFile)
88
-    {
80
+	/**
81
+	 * Optimize an image
82
+	 *
83
+	 * @param UploadedFileInterface $uploadedFile
84
+	 * @return UploadedFileInterface
85
+	 * @throws \InvalidArgumentException
86
+	 */
87
+	public function optimize(UploadedFileInterface $uploadedFile)
88
+	{
89 89
 
90
-        foreach ($this->optimizers as $optimizer) {
90
+		foreach ($this->optimizers as $optimizer) {
91 91
 
92
-            /** @var $optimizer \Fab\Media\FileUpload\ImageOptimizerInterface */
93
-            $optimizer = GeneralUtility::makeInstance($optimizer, $this->storage);
94
-            $uploadedFile = $optimizer->optimize($uploadedFile);
95
-        }
92
+			/** @var $optimizer \Fab\Media\FileUpload\ImageOptimizerInterface */
93
+			$optimizer = GeneralUtility::makeInstance($optimizer, $this->storage);
94
+			$uploadedFile = $optimizer->optimize($uploadedFile);
95
+		}
96 96
 
97
-        return $uploadedFile;
98
-    }
97
+		return $uploadedFile;
98
+	}
99 99
 }
Please login to merge, or discard this patch.