Skip to content

Commit

Permalink
Merge pull request #1 from vazaha-nl/abstracts-separation
Browse files Browse the repository at this point in the history
refactored away abstract request classes; separated other abstracts
  • Loading branch information
vazaha-nl authored Aug 10, 2023
2 parents 7e109aa + 3c8aa77 commit 2f15806
Show file tree
Hide file tree
Showing 457 changed files with 1,838 additions and 1,595 deletions.
3 changes: 1 addition & 2 deletions src/Models/Model.php → src/Abstracts/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Models;
namespace Vazaha\Mastodon\Abstracts;

use Carbon\Carbon;
use DateTimeInterface;
use ReflectionClass;
use ReflectionNamedType;
use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Interfaces\ModelInterface;

abstract class Model implements ModelInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Collections;
namespace Vazaha\Mastodon\Abstracts;

use Illuminate\Support\Collection;

/**
* @template TKey of array-key
* @template TModel of \Vazaha\Mastodon\Models\Model
* @template TModel of \Vazaha\Mastodon\Abstracts\Model
*
* @extends Collection<TKey, TModel>
*/
abstract class ModelCollection extends Collection
{
/**
* @return class-string<\Vazaha\Mastodon\Models\Model>
* @return class-string<\Vazaha\Mastodon\Abstracts\Model>
*/
abstract public static function getModelClass(): string;

Expand Down
2 changes: 1 addition & 1 deletion src/Proxies/Proxy.php → src/Abstracts/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Proxies;
namespace Vazaha\Mastodon\Abstracts;

use Vazaha\Mastodon\ApiClient;

Expand Down
5 changes: 2 additions & 3 deletions src/Requests/Request.php → src/Abstracts/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Requests;
namespace Vazaha\Mastodon\Abstracts;

use Vazaha\Mastodon\Helpers\MultipartFormData;
use Vazaha\Mastodon\Interfaces\RequestInterface;
use Vazaha\Mastodon\Requests\Concerns\HasPaging;
use Vazaha\Mastodon\Results\Result;

/**
* @implements \Vazaha\Mastodon\Interfaces\RequestInterface<\Vazaha\Mastodon\Results\Result>
* @implements \Vazaha\Mastodon\Interfaces\RequestInterface<\Vazaha\Mastodon\Abstracts\Result>
*/
abstract class Request implements RequestInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Results/Result.php → src/Abstracts/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Results;
namespace Vazaha\Mastodon\Abstracts;

use Illuminate\Support\Collection;
use Psr\Http\Message\ResponseInterface;
Expand All @@ -13,7 +13,7 @@
use Vazaha\Mastodon\Models\EmptyOrUnknownModel;
use Vazaha\Mastodon\Results\Concerns\HasPaging;

class Result extends Collection implements ResultInterface
abstract class Result extends Collection implements ResultInterface
{
use HasPaging;

Expand Down
1 change: 1 addition & 0 deletions src/Collections/AccountCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\AccountModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Admin/IpCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Admin;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Admin\IpModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Announcement/AccountCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Announcement;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Announcement\AccountModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Announcement/StatusCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Announcement;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Announcement\StatusModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/CohortDataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\CohortDataModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/CustomEmojiCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\CustomEmojiModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/FieldCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\FieldModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/FilterKeywordCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\FilterKeywordModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/FilterResultCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\FilterResultModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/FilterStatusCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\FilterStatusModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/MediaAttachmentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\MediaAttachmentModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Poll/OptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Poll;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Poll\OptionModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/ReactionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\ReactionModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/RuleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\RuleModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Status/MentionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Status;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Status\MentionModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collections/Status/TagCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Collections\Status;

use Vazaha\Mastodon\Collections\ModelCollection;
use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\Status\TagModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/StatusCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\StatusModel;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Collections/TagCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Vazaha\Mastodon\Collections;

use Vazaha\Mastodon\Abstracts\ModelCollection;
use Vazaha\Mastodon\Models\TagModel;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Vazaha\Mastodon\Factories;

use LogicException;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Interfaces\ModelInterface;
use Vazaha\Mastodon\Models\Model;

class ModelFactory
{
/**
* @template T of \Vazaha\Mastodon\Models\Model
* @template T of \Vazaha\Mastodon\Abstracts\Model
*
* @param class-string<T> $className
* @param mixed[] $modelData
Expand Down
4 changes: 2 additions & 2 deletions src/Factories/ResultFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use LogicException;
use Psr\Http\Message\ResponseInterface;
use Vazaha\Mastodon\Abstracts\Result;
use Vazaha\Mastodon\ApiClient;
use Vazaha\Mastodon\Interfaces\RequestInterface;
use Vazaha\Mastodon\Interfaces\ResultInterface;
use Vazaha\Mastodon\Results\Result;

class ResultFactory
{
/**
* @template T of \Vazaha\Mastodon\Results\Result
* @template T of \Vazaha\Mastodon\Abstracts\Result
* @template T2 of \Vazaha\Mastodon\Interfaces\ResultInterface
*
* @param class-string<T> $className
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vazaha\Mastodon\Results;
namespace Vazaha\Mastodon\Helpers;

class PagingLinks
{
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getFormParams(): array;
public function getOptions(): array;

/**
* @return class-string<\Vazaha\Mastodon\Results\Result>
* @return class-string<\Vazaha\Mastodon\Abstracts\Result>
*/
public function getResultClass(): string;

Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
interface ResultInterface
{
/**
* @return class-string<\Vazaha\Mastodon\Models\Model>
* @return class-string<\Vazaha\Mastodon\Abstracts\Model>
*/
public function getModelClass(): string;

Expand Down
1 change: 1 addition & 0 deletions src/Models/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Vazaha\Mastodon\Models;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\CustomEmojiCollection;
use Vazaha\Mastodon\Collections\FieldCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\Admin\IpCollection;
use Vazaha\Mastodon\Models\AccountModel as ModelsAccountModel;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Models\RoleModel;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/CanonicalEmailBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Models\Admin;

use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents a canonical email block (hashed).
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/CohortModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Abstracts\Model;
use Vazaha\Mastodon\Collections\CohortDataCollection;
use Vazaha\Mastodon\Models\Model;

/**
* Represents a retention metric.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/DimensionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Models\Admin;

use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents qualitative data about the server.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/DomainAllowModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents a domain allowed to federate.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/DomainBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents a domain limited from federating.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/EmailDomainBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents an email domain that cannot be used to sign up.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/IpBlockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents an IP address range that cannot be used to sign up.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/IpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Vazaha\Mastodon\Models\Admin;

use DateTimeInterface;
use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents an IP address associated with a user.
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Admin/MeasureModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Vazaha\Mastodon\Models\Admin;

use Vazaha\Mastodon\Models\Model;
use Vazaha\Mastodon\Abstracts\Model;

/**
* Represents quantitative data about the server.
Expand Down
Loading

0 comments on commit 2f15806

Please sign in to comment.