-
-
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.
Merge pull request #7 from phonetworks/space
Space
- Loading branch information
Showing
11 changed files
with
160 additions
and
187 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 |
---|---|---|
@@ -1 +1 @@ | ||
4.7.0 | ||
5.0.0 |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -12,57 +12,61 @@ | |
namespace Pho\Framework; | ||
|
||
/** | ||
* The Graph | ||
* The Frame Particle | ||
* | ||
* This class is a shell to Pho\Lib\Graph's Graph implementation | ||
* and it implements ContextInterface to give higher-level | ||
* software access to use both Frame and Graph as context objects. | ||
* At its core, Frame is a graph, or more specifically, a subgraph. | ||
* It extends the Pho\Lib\Graph\SubGraph class, which is a regular node, | ||
* as well as a Graph (by way of using the Pho\Lib\Graph\ClusterTrait) | ||
* both at the same time. It implements both Pho\Lib\Graph\GraphInterface | ||
* and Pho\Lib\Graph\NodeInterface. In order to prevent | ||
* any confusions with Pho\Lib\Graph's nomenclature, this class is called | ||
* Frame instead. | ||
* | ||
* In contrast to other particles, Frame doesn't contain edges but | ||
* its **"contains"** method acts similarly to an edge. | ||
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
class Graph extends \Pho\Lib\Graph\Graph implements ContextInterface | ||
class Graph extends \Pho\Lib\Graph\SubGraph implements ParticleInterface, ContextInterface | ||
{ | ||
|
||
/** | ||
* The title of the graph. | ||
* | ||
* @var string | ||
*/ | ||
protected $title; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* The title allows one to host multiple graphs in a single PHP instance. | ||
* | ||
* @param string $title Optional. Leave blank for a random title. | ||
*/ | ||
public function __construct(string $title = "") | ||
{ | ||
if(empty($title)) { | ||
$this->title = uniqid("graph_", true); | ||
} | ||
else { | ||
$this->title = $title; | ||
} | ||
use ParticleTrait { | ||
ParticleTrait::__construct as particleConstructor; | ||
} | ||
|
||
/** | ||
* Returns the title of the graph. | ||
* | ||
* @return string | ||
*/ | ||
public function title(): string | ||
public function __construct(Actor $creator, ContextInterface $context) | ||
{ | ||
return $this->title; | ||
parent::__construct($context); | ||
$this->creator = $creator; | ||
$this->creator_id = (string) $creator->id(); | ||
$this->registerIncomingEdges(ActorOut\Write::class); | ||
$this->particleConstructor(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function belongsOrEquals(ContextInterface $context): bool | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function in(ContextInterface $context): bool | ||
{ | ||
return $context instanceof Graph && $this->title == $context->title(); | ||
/* | ||
// would speed up, but not good for testing. | ||
if($context instanceof Space) | ||
return true; | ||
*/ | ||
$members = $context->members(); | ||
foreach($members as $member) { | ||
if($member instanceof Graph) { | ||
if($member->id() == $this->id()) { | ||
return true; | ||
} | ||
else { | ||
if($this->in($member)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
src/Pho/Framework/FrameOut/README.md → src/Pho/Framework/GraphOut/README.md
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,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Pho package. | ||
* | ||
* (c) Emre Sokullu <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pho\Framework; | ||
|
||
/** | ||
* The Space | ||
* | ||
* This class is a shell to Pho\Lib\Graph's Graph implementation | ||
* and it implements ContextInterface to give higher-level | ||
* software access to use both Frame and Graph as context objects. | ||
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
class Space extends \Pho\Lib\Graph\Graph implements ContextInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function in(ContextInterface $context): bool | ||
{ | ||
return $context instanceof Space; | ||
} | ||
|
||
} |
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
Oops, something went wrong.