Implemented \ncc\Objects\ProjectConfiguration > updateSource
https://git.n64.cc/nosial/ncc/-/issues/34
This commit is contained in:
parent
3757c970a5
commit
b4acfaa0cb
1 changed files with 51 additions and 1 deletions
|
@ -1,8 +1,58 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
|
use ncc\Objects\ProjectConfiguration\UpdateSource\Repository;
|
||||||
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class UpdateSource
|
class UpdateSource
|
||||||
{
|
{
|
||||||
public $type;
|
/**
|
||||||
|
* The string format of where the source is located.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $Source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The repository to use for the source
|
||||||
|
*
|
||||||
|
* @var Repository|null
|
||||||
|
*/
|
||||||
|
public $Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array representation of the object
|
||||||
|
*
|
||||||
|
* @param bool $bytecode
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray(bool $bytecode=false): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
($bytecode ? Functions::cbc('source') : 'source') => $this->Source,
|
||||||
|
($bytecode ? Functions::cbc('repository') : 'repository') => ($this->Repository?->toArray($bytecode))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs object from an array representation
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return UpdateSource
|
||||||
|
*/
|
||||||
|
public static function fromArray(array $data): UpdateSource
|
||||||
|
{
|
||||||
|
$obj = new UpdateSource();
|
||||||
|
$obj->Source = Functions::array_bc($data, 'source');
|
||||||
|
$obj->Repository = Functions::array_bc($data, 'repository');
|
||||||
|
|
||||||
|
if($obj->Repository !== null)
|
||||||
|
$obj->Repository = Repository::fromArray($obj->Repository);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue