Skip to content

Commit

Permalink
Update doc blocks to reflect new style guide (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack97 committed Oct 30, 2019
1 parent 2a0ddea commit f101376
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 86 deletions.
12 changes: 5 additions & 7 deletions src/ConversionRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class ConversionRegistry
{
/**
* @var array
*/
/** @var array */
protected $conversions = [];

/**
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class InvalidConversion extends Exception
{
/**
* @param string $name
* @param string $name
* @return InvalidConversion
*/
public static function doesNotExist($name)
Expand Down
35 changes: 17 additions & 18 deletions src/HasMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

trait HasMedia
{
/**
* @var MediaGroup[]
*/
/** @var MediaGroup[] */
protected $mediaGroups = [];

/**
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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 = '')
Expand All @@ -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 = [])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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')
Expand Down
25 changes: 13 additions & 12 deletions src/ImageManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
22 changes: 7 additions & 15 deletions src/Jobs/PerformConversions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/MediaGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 15 additions & 23 deletions src/MediaUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -38,7 +30,7 @@ public function __construct(UploadedFile $file)
}

/**
* @param UploadedFile $file
* @param UploadedFile $file
* @return MediaUploader
*/
public static function fromFile(UploadedFile $file)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -79,7 +71,7 @@ public function setName(string $name)
}

/**
* @param string $name
* @param string $name
* @return MediaUploader
*/
public function useName(string $name)
Expand All @@ -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)
Expand All @@ -101,7 +93,7 @@ public function setFileName(string $fileName)
}

/**
* @param string $fileName
* @param string $fileName
* @return MediaUploader
*/
public function useFileName(string $fileName)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -134,7 +126,7 @@ public function withAttributes(array $attributes)
}

/**
* @param array $properties
* @param array $properties
* @return MediaUploader
*/
public function withProperties(array $properties)
Expand Down
Loading

0 comments on commit f101376

Please sign in to comment.