Skip to content

Commit

Permalink
Added an improved doc block to the QueryBuilder (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonrietdijk authored Jul 31, 2023
1 parent 1ba655d commit 2e92b44
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/OData/BaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ abstract class BaseResource implements ArrayAccess, Arrayable

public string $endpoint;

final public function __construct(?string $connection = null, ?string $endpoint = null)
final public function __construct(string $connection = null, string $endpoint = null)
{
$this->connection ??= $connection ?? config('dynamics.connection');
$this->endpoint ??= $endpoint ?? config('dynamics.resources.'.static::class,
Str::afterLast(static::class, '\\'));
}

public static function new(?string $connection = null, ?string $endpoint = null): static
public static function new(string $connection = null, string $endpoint = null): static
{
return new static($connection, $endpoint);
}

public static function query(?string $connection = null, ?string $endpoint = null): QueryBuilder
public static function query(string $connection = null, string $endpoint = null): QueryBuilder
{
return static::new($connection, $endpoint)->newQuery();
}
Expand Down Expand Up @@ -128,7 +128,7 @@ public function etag(bool $force = false): string
: $this->data['odata.etag'];
}

public function client(?string $etag = null): ODataClient
public function client(string $etag = null): ODataClient
{
$factory = ClientFactory::make($this->connection);

Expand Down
31 changes: 29 additions & 2 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,34 @@
use SaintSystems\OData\ODataClient;
use SaintSystems\OData\Query\Builder;

/** @mixin Builder */
/**
* @method static select(array|mixed $properties = [])
* @method static addSelect(array|mixed $select)
* @method static from(string $entitySet)
* @method static whereKey(string $id)
* @method static expand(array $properties = [])
* @method static order(array|mixed $properties = [])
* @method static orderBySQL(string $sql = '')
* @method static mergeWheres(array $wheres, array $bindings)
* @method static where(string|array|\Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and')
* @method static orWhere(string|array|\Closure $column, string $operator = null, mixed $value = null)
* @method static whereRaw(string $rawString, string $boolean = 'and')
* @method static orWhereRaw(string $rawString)
* @method static whereDate(string|array|\Closure $column, string $operator = null, mixed $value = null, string $boolean = 'and')
* @method static orWhereDate(string|array|\Closure $column, string $operator = null, mixed $value = null)
* @method static whereColumn(string|array $first, string $operator = null, string $second = null, string $boolean = 'and')
* @method static orWhereColumn(string|array $first, string $operator = null, string $second = null)
* @method static whereNested(\Closure $callback, string $boolean = 'and')
* @method static forNestedWhere()
* @method static addNestedWhereQuery(self $query, string $boolean = 'and')
* @method static whereNull(string $column, string $boolean = 'and', bool $not = false)
* @method static orWhereNull(string $column)
* @method static whereNotNull(string $column, string $boolean = 'and')
* @method static orWhereNotNull(string $column)
* @method static skip(int $value)
* @method static take(int $value)
* @method static addBinding(mixed $value, string $type = 'where')
*/
class QueryBuilder
{
protected Builder $builder;
Expand Down Expand Up @@ -123,7 +150,7 @@ public function firstOrCreate(array $attributes = [], array $values = []): BaseR
return $this->newResourceInstance()->create($data);
}

public function lazy(?int $pageSize = null): LazyCollection
public function lazy(int $pageSize = null): LazyCollection
{
return LazyCollection::make(function () use ($pageSize): Generator {
$pageSize ??= (int) config('dynamics.connections.'.$this->connection.'.page_size');
Expand Down

0 comments on commit 2e92b44

Please sign in to comment.