forked from scriptotek/php-alma-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Scriptotek\Alma\Conf; | ||
|
||
use Scriptotek\Alma\Client; | ||
use Scriptotek\Alma\Model\LazyResource; | ||
|
||
/** | ||
* A single CodeTable resource. | ||
*/ | ||
class CodeTable extends LazyResource | ||
{ | ||
/** @var string */ | ||
public $code; | ||
|
||
/** | ||
* CodeTable constructor. | ||
* | ||
* @param Client $client | ||
* @param string $code | ||
*/ | ||
public function __construct(Client $client, $code) | ||
{ | ||
parent::__construct($client); | ||
$this->code = $code; | ||
} | ||
|
||
/** | ||
* Check if we have the full representation of our data object. | ||
* | ||
* @param \stdClass $data | ||
* | ||
* @return bool | ||
*/ | ||
protected function isInitialized($data) | ||
{ | ||
return isset($data->name); | ||
} | ||
|
||
/** | ||
* Generate the base URL for this resource. | ||
* | ||
* @return string | ||
*/ | ||
protected function urlBase() | ||
{ | ||
return "/conf/code-tables/{$this->code}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Scriptotek\Alma\Conf; | ||
|
||
use Scriptotek\Alma\Client; | ||
use Scriptotek\Alma\Model\ReadOnlyArrayAccess; | ||
|
||
/** | ||
* A non-iterable collection of CodeTable resources | ||
*/ | ||
class CodeTables implements \ArrayAccess | ||
{ | ||
use ReadOnlyArrayAccess; | ||
|
||
protected $client; | ||
|
||
/** | ||
* CodeTables constructor. | ||
* | ||
* @param Client $client | ||
*/ | ||
public function __construct(Client $client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
/** | ||
* Get a CodeTable by identifier | ||
* | ||
* @param $code The identifier of a CodeTable | ||
* | ||
* @return CodeTable | ||
*/ | ||
public function get($code) | ||
{ | ||
return CodeTable::make($this->client, $code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters