Skip to content

Commit

Permalink
more tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Mar 28, 2019
1 parent 4be7e9f commit eef0b9e
Show file tree
Hide file tree
Showing 61 changed files with 1,609 additions and 26 deletions.
25 changes: 25 additions & 0 deletions src/Annotation/Relation/BelongsTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\Parser;

final class BelongsTo extends Relation
{
protected const NAME = 'belongsTo';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'fkCreate' => Parser::BOOL,
'fkAction' => Parser::STRING,
'indexCreate' => Parser::BOOL,
];
}
26 changes: 26 additions & 0 deletions src/Annotation/Relation/HasMany.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\Parser;

final class HasMany extends Relation
{
protected const NAME = 'hasMany';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'where' => [Parser::MIXED],
'fkCreate' => Parser::BOOL,
'fkAction' => Parser::STRING,
'indexCreate' => Parser::BOOL,
];
}
16 changes: 13 additions & 3 deletions src/Annotation/Relation/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\AbstractAnnotation;
use Spiral\Annotations\Parser;

final class HasOne extends AbstractAnnotation
final class HasOne extends Relation
{

protected const NAME = 'hasOne';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'where' => [Parser::MIXED],
'fkCreate' => Parser::BOOL,
'fkAction' => Parser::STRING,
'indexCreate' => Parser::BOOL,
];
}
51 changes: 51 additions & 0 deletions src/Annotation/Relation/Inversed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\AbstractAnnotation;
use Spiral\Annotations\Parser;

final class Inversed extends AbstractAnnotation
{
protected const INVERSED = 'inversed';
protected const SCHEMA = [
'type' => Parser::STRING,
'name' => Parser::STRING
];

/** @var string|null */
protected $type;

/** @var string|null */
protected $name;

/**
* @return bool
*/
public function isValid(): bool
{
return $this->type !== null && $this->name !== null;
}

/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}

/**
* @return string|null
*/
public function getRelation(): ?string
{
return $this->name;
}
}
31 changes: 31 additions & 0 deletions src/Annotation/Relation/ManyToMany.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\Parser;

final class ManyToMany extends Relation
{
protected const NAME = 'manyToMany';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'though' => Parser::STRING,
'thoughInnerKey' => Parser::STRING,
'thoughOuterKey' => Parser::STRING,
'thoughConstrain' => Parser::STRING,
'thoughWhere' => [Parser::MIXED],
'where' => [Parser::MIXED],
'fkCreate' => Parser::BOOL,
'fkAction' => Parser::STRING,
'indexCreate' => Parser::BOOL,
];
}
26 changes: 26 additions & 0 deletions src/Annotation/Relation/Morphed/BelongsToMorphed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation\Morphed;

use Cycle\Annotated\Annotation\Relation\Relation;
use Spiral\Annotations\Parser;

final class BelongsToMorphed extends Relation
{
protected const NAME = 'belongsToMorphed';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'morphKey' => Parser::STRING,
'morphKeyLength' => Parser::INTEGER,
'indexCreate' => Parser::BOOL,
];
}
27 changes: 27 additions & 0 deletions src/Annotation/Relation/Morphed/MorphedHasMany.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation\Morphed;

use Cycle\Annotated\Annotation\Relation\Relation;
use Spiral\Annotations\Parser;

final class MorphedHasMany extends Relation
{
protected const NAME = 'morphedHasMany';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'morphKey' => Parser::STRING,
'morphKeyLength' => Parser::INTEGER,
'where' => [Parser::MIXED],
'indexCreate' => Parser::BOOL,
];
}
27 changes: 27 additions & 0 deletions src/Annotation/Relation/Morphed/MorphedHasOne.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation\Morphed;

use Cycle\Annotated\Annotation\Relation\Relation;
use Spiral\Annotations\Parser;

final class MorphedHasOne extends Relation
{
protected const NAME = 'morphedHasOne';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'morphKey' => Parser::STRING,
'morphKeyLength' => Parser::INTEGER,
'where' => [Parser::MIXED],
'indexCreate' => Parser::BOOL,
];
}
25 changes: 25 additions & 0 deletions src/Annotation/Relation/RefersTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/

namespace Cycle\Annotated\Annotation\Relation;

use Spiral\Annotations\Parser;

final class RefersTo extends Relation
{
protected const NAME = 'refersTo';
protected const OPTIONS = [
'cascade' => Parser::BOOL,
'nullable' => Parser::BOOL,
'innerKey' => Parser::STRING,
'outerKey' => Parser::STRING,
'fkCreate' => Parser::BOOL,
'fkAction' => Parser::STRING,
'indexCreate' => Parser::BOOL,
];
}
Loading

0 comments on commit eef0b9e

Please sign in to comment.