ReviewOS

also looking at this

meemalabs/meema-client-php

Implement Feature Exception

#72
Merged glennmichael123 wants to merge implement-feature-exception into main
5 files +39 -3

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

src/Client.phpmodified+1-1
Changes to src/Client.php
@@ -176,7 +176,7 @@ class Client
176176 *
177177 * @return Meema\MeemaClient\Functions\Video
178178 */
179 public function videos(): Video
179 public function video(): Video
180180 {
181181 return new Video($this);
182182 }
src/Exceptions/InvalidFormatException.php src/Exceptions/FeatureNotImplementedException.phpcopied+1-1
Changes to src/Exceptions/FeatureNotImplementedException.php
@@ -4,7 +4,7 @@ namespace Meema\MeemaClient\Exceptions;
44
55use Exception;
66
7class InvalidFormatException extends Exception
7class FeatureNotImplementedException extends Exception
88{
99 /**
1010 * Construct exception.
src/Exceptions/InvalidFormatException.phpmodified+1-1
Changes to src/Exceptions/InvalidFormatException.php
@@ -14,6 +14,6 @@ class InvalidFormatException extends Exception
1414 public function __construct(string $message = null)
1515 {
1616 parent::__construct($message ?? 'Error on line '.$this->getLine().' in '.$this->getFile()
17 .' ID is not a valid integer');
17 .' Feature not yet implemented. Please contact us if this is something you would like to see rather sooner than later.');
1818 }
1919}
src/Functions/Image.phpmodified+2-1
Changes to src/Functions/Image.php
@@ -4,10 +4,11 @@ namespace Meema\MeemaClient\Functions;
44
55use Meema\MeemaClient\Client;
66use Meema\MeemaClient\Traits\UrlResponse;
7use Meema\MeemaClient\Traits\DetectsFeature;
78
89class Image
910{
10 use UrlResponse;
11 use UrlResponse, DetectsFeature;
1112
1213 /**
1314 * @var \Meema\MeemaClient\Client
src/Functions/Video.phpmodified+2-1
Changes to src/Functions/Video.php
@@ -3,11 +3,12 @@
33namespace Meema\MeemaClient\Functions;
44
55use Meema\MeemaClient\Client;
6use Meema\MeemaClient\Traits\DetectsFeature;
67use Meema\MeemaClient\Traits\UrlResponse;
78
89class Video
910{
10 use UrlResponse;
11 use UrlResponse, DetectsFeature;
1112
1213 /**
1314 * @var \Meema\MeemaClient\Client
src/Traits/DetectsFeature.phpadded+15-0
Changes to src/Traits/DetectsFeature.php
@@ -0,0 +1,15 @@
1<?php
2
3namespace Meema\MeemaClient\Traits;
4
5use Meema\MeemaClient\Exceptions\FeatureNotImplementedException;
6
7trait DetectsFeature
8{
9 public function __call($name, $arguments)
10 {
11 if (! method_exists($this, $name)) {
12 throw new FeatureNotImplementedException('Feature not yet implemented. Please contact us if this is something you would like to see rather sooner than later.');
13 }
14 }
15}