1<?php 2/** 3 * Copyright 2017 Facebook, Inc. 4 * 5 * You are hereby granted a non-exclusive, worldwide, royalty-free license to 6 * use, copy, modify, and distribute this software in source code or binary 7 * form for use in connection with the web services and APIs provided by 8 * Facebook. 9 * 10 * As with any software that integrates with the Facebook platform, your use 11 * of this software is subject to the Facebook Developer Principles and 12 * Policies [http://developers.facebook.com/policy/]. This copyright notice 13 * shall be included in all copies or substantial portions of the software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 */ 24namespace Facebook\GraphNodes; 25 26/** 27 * Class GraphAchievement 28 * 29 * @package Facebook 30 */ 31class GraphAchievement extends GraphNode 32{ 33 /** 34 * @var array Maps object key names to Graph object types. 35 */ 36 protected static $graphObjectMap = [ 37 'from' => '\Facebook\GraphNodes\GraphUser', 38 'application' => '\Facebook\GraphNodes\GraphApplication', 39 ]; 40 41 /** 42 * Returns the ID for the achievement. 43 * 44 * @return string|null 45 */ 46 public function getId() 47 { 48 return $this->getField('id'); 49 } 50 51 /** 52 * Returns the user who achieved this. 53 * 54 * @return GraphUser|null 55 */ 56 public function getFrom() 57 { 58 return $this->getField('from'); 59 } 60 61 /** 62 * Returns the time at which this was achieved. 63 * 64 * @return \DateTime|null 65 */ 66 public function getPublishTime() 67 { 68 return $this->getField('publish_time'); 69 } 70 71 /** 72 * Returns the app in which the user achieved this. 73 * 74 * @return GraphApplication|null 75 */ 76 public function getApplication() 77 { 78 return $this->getField('application'); 79 } 80 81 /** 82 * Returns information about the achievement type this instance is connected with. 83 * 84 * @return array|null 85 */ 86 public function getData() 87 { 88 return $this->getField('data'); 89 } 90 91 /** 92 * Returns the type of achievement. 93 * 94 * @see https://developers.facebook.com/docs/graph-api/reference/achievement 95 * 96 * @return string 97 */ 98 public function getType() 99 { 100 return 'game.achievement'; 101 } 102 103 /** 104 * Indicates whether gaining the achievement published a feed story for the user. 105 * 106 * @return boolean|null 107 */ 108 public function isNoFeedStory() 109 { 110 return $this->getField('no_feed_story'); 111 } 112} 113