Skip to content

Commit bf860d7

Browse files
committed
agent profile API implementation
1 parent f6fed79 commit bf860d7

File tree

6 files changed

+185
-0
lines changed

6 files changed

+185
-0
lines changed

Model/AgentProfile.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link ProfileInterface Profile} related to an {@link AgentInterface Agent}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class AgentProfile extends Profile implements AgentProfileInterface
20+
{
21+
/**
22+
* @var AgentInterface The agent
23+
*/
24+
private $agent;
25+
26+
/**
27+
* {@inheritDoc}
28+
*/
29+
public function setAgent(AgentInterface $agent)
30+
{
31+
$this->agent = $agent;
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*/
37+
public function getAgent()
38+
{
39+
return $this->agent;
40+
}
41+
}

Model/AgentProfileDocument.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link DocumentInterface Document} that is related to an {@link AgentInterface Agent}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class AgentProfileDocument extends Document implements AgentProfileDocumentInterface
20+
{
21+
/**
22+
* @var AgentProfileInterface The agent profile
23+
*/
24+
private $profile;
25+
26+
/**
27+
* Sets the agent profile.
28+
*
29+
* @param AgentProfileInterface $profile The agent profile
30+
*/
31+
public function setAgentProfile(AgentProfileInterface $profile)
32+
{
33+
$this->profile = $profile;
34+
}
35+
36+
/**
37+
* Returns the agent profile.
38+
*
39+
* @return AgentProfileInterface The agent profile
40+
*/
41+
public function getAgentProfile()
42+
{
43+
return $this->profile;
44+
}
45+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link DocumentInterface Document} that is related to an {@link AgentInterface Agent}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
interface AgentProfileDocumentInterface extends DocumentInterface
20+
{
21+
/**
22+
* Sets the agent profile.
23+
*
24+
* @param AgentProfileInterface $profile The agent profile
25+
*/
26+
public function setAgentProfile(AgentProfileInterface $profile);
27+
28+
/**
29+
* Returns the agent profile.
30+
*
31+
* @return AgentProfileInterface The agent profile
32+
*/
33+
public function getAgentProfile();
34+
}

Model/AgentProfileInterface.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Model;
13+
14+
/**
15+
* A {@link ProfileInterface Profile} related to an {@link AgentInterface Agent}.
16+
*
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
interface AgentProfileInterface extends ProfileInterface
20+
{
21+
/**
22+
* Sets the agent.
23+
*
24+
* @param AgentInterface $agent The agent
25+
*/
26+
public function setAgent(AgentInterface $agent);
27+
28+
/**
29+
* Returns the agent.
30+
*
31+
* @return AgentInterface The agent
32+
*/
33+
public function getAgent();
34+
}

Serializer/Handler/DocumentDataUnwrapper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public static function getSubscribingMethods()
4242
'type' => 'Xabbuh\XApi\Common\Model\ActivityProfileDocument',
4343
'method' => 'unwrapData',
4444
),
45+
array(
46+
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
47+
'format' => 'json',
48+
'type' => 'Xabbuh\XApi\Common\Model\AgentProfileDocument',
49+
'method' => 'unwrapData',
50+
),
4551
array(
4652
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
4753
'format' => 'json',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the xAPI package.
5+
*
6+
* (c) Christian Flothmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Xabbuh\XApi\Common\Tests\Model;
13+
14+
use Xabbuh\XApi\Common\Model\AgentProfileDocument;
15+
16+
/**
17+
* @author Christian Flothmann <[email protected]>
18+
*/
19+
class AgentProfileDocumentTest extends DocumentTest
20+
{
21+
protected function createDocument()
22+
{
23+
return new AgentProfileDocument();
24+
}
25+
}

0 commit comments

Comments
 (0)