From f101376a7ed3915299ba1211e5ae7e0af25e8c2e Mon Sep 17 00:00:00 2001 From: Jack Robertson Date: Wed, 30 Oct 2019 12:48:18 +0000 Subject: [PATCH] Update doc blocks to reflect new style guide (#23) --- src/ConversionRegistry.php | 12 ++++----- src/Exceptions/InvalidConversion.php | 2 +- src/HasMedia.php | 35 +++++++++++++------------ src/ImageManipulator.php | 25 +++++++++--------- src/Jobs/PerformConversions.php | 22 +++++----------- src/MediaGroup.php | 6 ++--- src/MediaUploader.php | 38 +++++++++++----------------- src/Models/Media.php | 16 +++++++----- 8 files changed, 70 insertions(+), 86 deletions(-) diff --git a/src/ConversionRegistry.php b/src/ConversionRegistry.php index 7f487e7..6c5ae6d 100644 --- a/src/ConversionRegistry.php +++ b/src/ConversionRegistry.php @@ -6,9 +6,7 @@ class ConversionRegistry { - /** - * @var array - */ + /** @var array */ protected $conversions = []; /** @@ -24,8 +22,8 @@ public function all() /** * Register a new conversion. * - * @param string $name - * @param callable $conversion + * @param string $name + * @param callable $conversion * @return void */ public function register(string $name, callable $conversion) @@ -36,7 +34,7 @@ public function register(string $name, callable $conversion) /** * Get the conversion with the specified name. * - * @param string $name + * @param string $name * @return mixed * * @throws InvalidConversion @@ -53,7 +51,7 @@ public function get(string $name) /** * Determine if a conversion with the specified name exists. * - * @param string $name + * @param string $name * @return bool */ public function exists(string $name) diff --git a/src/Exceptions/InvalidConversion.php b/src/Exceptions/InvalidConversion.php index bc776f5..0c06c98 100644 --- a/src/Exceptions/InvalidConversion.php +++ b/src/Exceptions/InvalidConversion.php @@ -7,7 +7,7 @@ class InvalidConversion extends Exception { /** - * @param string $name + * @param string $name * @return InvalidConversion */ public static function doesNotExist($name) diff --git a/src/HasMedia.php b/src/HasMedia.php index 32a4949..a5f10e7 100644 --- a/src/HasMedia.php +++ b/src/HasMedia.php @@ -9,9 +9,7 @@ trait HasMedia { - /** - * @var MediaGroup[] - */ + /** @var MediaGroup[] */ protected $mediaGroups = []; /** @@ -21,14 +19,15 @@ trait HasMedia */ public function media() { - return $this->morphToMany(config('media.model'), 'mediable') - ->withPivot('group'); + return $this + ->morphToMany(config('media.model'), 'mediable') + ->withPivot('group'); } /** * Determine if there is any media in the specified group. * - * @param string $group + * @param string $group * @return mixed */ public function hasMedia(string $group = 'default') @@ -39,7 +38,7 @@ public function hasMedia(string $group = 'default') /** * Get all the media in the specified group. * - * @param string $group + * @param string $group * @return mixed */ public function getMedia(string $group = 'default') @@ -50,7 +49,7 @@ public function getMedia(string $group = 'default') /** * Get the first media item in the specified group. * - * @param string $group + * @param string $group * @return mixed */ public function getFirstMedia(string $group = 'default') @@ -61,8 +60,8 @@ public function getFirstMedia(string $group = 'default') /** * Get the url of the first media item in the specified group. * - * @param string $group - * @param string $conversion + * @param string $group + * @param string $conversion * @return string */ public function getFirstMediaUrl(string $group = 'default', string $conversion = '') @@ -77,9 +76,9 @@ public function getFirstMediaUrl(string $group = 'default', string $conversion = /** * Attach media to the specified group. * - * @param mixed $media - * @param string $group - * @param array $conversions + * @param mixed $media + * @param string $group + * @param array $conversions * @return void */ public function attachMedia($media, string $group = 'default', array $conversions = []) @@ -116,7 +115,7 @@ public function attachMedia($media, string $group = 'default', array $conversion /** * Parse the media id's from the mixed input. * - * @param mixed $media + * @param mixed $media * @return array */ protected function parseMediaIds($media) @@ -145,7 +144,7 @@ public function registerMediaGroups() /** * Register a new media group. * - * @param string $name + * @param string $name * @return MediaGroup */ protected function addMediaGroup(string $name) @@ -160,7 +159,7 @@ protected function addMediaGroup(string $name) /** * Get the media group with the specified name. * - * @param string $name + * @param string $name * @return MediaGroup|null */ public function getMediaGroup(string $name) @@ -171,7 +170,7 @@ public function getMediaGroup(string $name) /** * Detach the specified media. * - * @param null $media + * @param mixed $media * @return void */ public function detachMedia($media = null) @@ -182,7 +181,7 @@ public function detachMedia($media = null) /** * Detach all the media in the specified group. * - * @param string $group + * @param string $group * @return void */ public function clearMediaGroup(string $group = 'default') diff --git a/src/ImageManipulator.php b/src/ImageManipulator.php index 0de7156..a288de4 100644 --- a/src/ImageManipulator.php +++ b/src/ImageManipulator.php @@ -4,24 +4,22 @@ use Optix\Media\Models\Media; use Intervention\Image\ImageManager; +use Optix\Media\Exceptions\InvalidConversion; +use Illuminate\Contracts\Filesystem\FileNotFoundException; class ImageManipulator { - /** - * @var ConversionRegistry - */ + /** @var ConversionRegistry */ protected $conversionRegistry; - /** - * @var ImageManager - */ + /** @var ImageManager */ protected $imageManager; /** - * Create a new ImageManipulator instance. + * Create a new manipulator instance. * - * @param ConversionRegistry $conversionRegistry - * @param ImageManager $imageManager + * @param ConversionRegistry $conversionRegistry + * @param ImageManager $imageManager * @return void */ public function __construct(ConversionRegistry $conversionRegistry, ImageManager $imageManager) @@ -34,10 +32,13 @@ public function __construct(ConversionRegistry $conversionRegistry, ImageManager /** * Perform the specified conversions on the given media item. * - * @param Media $media - * @param array $conversions - * @param bool $onlyIfMissing + * @param Media $media + * @param array $conversions + * @param bool $onlyIfMissing * @return void + * + * @throws InvalidConversion + * @throws FileNotFoundException */ public function manipulate(Media $media, array $conversions, $onlyIfMissing = true) { diff --git a/src/Jobs/PerformConversions.php b/src/Jobs/PerformConversions.php index d3c2680..d82c8ec 100644 --- a/src/Jobs/PerformConversions.php +++ b/src/Jobs/PerformConversions.php @@ -14,21 +14,17 @@ class PerformConversions implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - /** - * @var Media - */ + /** @var Media */ protected $media; - /** - * @var array - */ + /** @var array */ protected $conversions; /** - * Create a new PerformConversions instance. + * Create a new job instance. * - * @param Media $media - * @param array $conversions + * @param Media $media + * @param array $conversions * @return void */ public function __construct(Media $media, array $conversions) @@ -50,17 +46,13 @@ public function handle() ); } - /** - * @return Media - */ + /** @return Media */ public function getMedia() { return $this->media; } - /** - * @return array - */ + /** @return array */ public function getConversions() { return $this->conversions; diff --git a/src/MediaGroup.php b/src/MediaGroup.php index a2980ff..e877c9e 100644 --- a/src/MediaGroup.php +++ b/src/MediaGroup.php @@ -4,15 +4,13 @@ class MediaGroup { - /** - * @var array - */ + /** @var array */ protected $conversions = []; /** * Register the conversions to be performed when media is attached. * - * @param string ...$conversions + * @param string ...$conversions * @return $this */ public function performConversions(...$conversions) diff --git a/src/MediaUploader.php b/src/MediaUploader.php index f389ba8..1a80c6e 100644 --- a/src/MediaUploader.php +++ b/src/MediaUploader.php @@ -6,30 +6,22 @@ class MediaUploader { - /** - * @var UploadedFile - */ + /** @var UploadedFile */ protected $file; - /** - * @var string - */ + /** @var string */ protected $name; - /** - * @var string - */ + /** @var string */ protected $fileName; - /** - * @var array - */ + /** @var array */ protected $attributes = []; /** - * Create a new MediaUploader instance. + * Create a new uploader instance. * - * @param UploadedFile $file + * @param UploadedFile $file * @return void */ public function __construct(UploadedFile $file) @@ -38,7 +30,7 @@ public function __construct(UploadedFile $file) } /** - * @param UploadedFile $file + * @param UploadedFile $file * @return MediaUploader */ public static function fromFile(UploadedFile $file) @@ -49,7 +41,7 @@ public static function fromFile(UploadedFile $file) /** * Set the file to be uploaded. * - * @param UploadedFile $file + * @param UploadedFile $file * @return MediaUploader */ public function setFile(UploadedFile $file) @@ -68,7 +60,7 @@ public function setFile(UploadedFile $file) /** * Set the name of the media item. * - * @param string $name + * @param string $name * @return MediaUploader */ public function setName(string $name) @@ -79,7 +71,7 @@ public function setName(string $name) } /** - * @param string $name + * @param string $name * @return MediaUploader */ public function useName(string $name) @@ -90,7 +82,7 @@ public function useName(string $name) /** * Set the name of the file. * - * @param string $fileName + * @param string $fileName * @return MediaUploader */ public function setFileName(string $fileName) @@ -101,7 +93,7 @@ public function setFileName(string $fileName) } /** - * @param string $fileName + * @param string $fileName * @return MediaUploader */ public function useFileName(string $fileName) @@ -112,7 +104,7 @@ public function useFileName(string $fileName) /** * Sanitise the file name. * - * @param string $fileName + * @param string $fileName * @return string */ protected function sanitiseFileName(string $fileName) @@ -123,7 +115,7 @@ protected function sanitiseFileName(string $fileName) /** * Set any custom attributes to be saved to the media item. * - * @param array $attributes + * @param array $attributes * @return MediaUploader */ public function withAttributes(array $attributes) @@ -134,7 +126,7 @@ public function withAttributes(array $attributes) } /** - * @param array $properties + * @param array $properties * @return MediaUploader */ public function withProperties(array $properties) diff --git a/src/Models/Media.php b/src/Models/Media.php index 7436c57..bd9b2d7 100644 --- a/src/Models/Media.php +++ b/src/Models/Media.php @@ -41,7 +41,7 @@ public function getTypeAttribute() /** * Determine if the file is of the specified type. * - * @param string $type + * @param string $type * @return bool */ public function isOfType(string $type) @@ -52,29 +52,33 @@ public function isOfType(string $type) /** * Get the url to the file. * - * @param string $conversion + * @param string $conversion * @return mixed */ public function getUrl(string $conversion = '') { - return $this->filesystem()->url($this->getPath($conversion)); + return $this->filesystem()->url( + $this->getPath($conversion) + ); } /** * Get the full path to the file. * - * @param string $conversion + * @param string $conversion * @return mixed */ public function getFullPath(string $conversion = '') { - return $this->filesystem()->path($this->getPath($conversion)); + return $this->filesystem()->path( + $this->getPath($conversion) + ); } /** * Get the path to the file on disk. * - * @param string $conversion + * @param string $conversion * @return string */ public function getPath(string $conversion = '')