| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * (c) Kitodo. Key to digital objects e.V. <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Kitodo and TYPO3 projects. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @license GNU General Public License version 3 or later. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * For the full copyright and license information, please read the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * LICENSE.txt file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | namespace Kitodo\Dlf\Api\Orcid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Kitodo\Dlf\Common\Helper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use TYPO3\CMS\Core\Http\RequestFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use TYPO3\CMS\Core\Log\LogManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * ORCID API Profile class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @author Beatrycze Volk <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @package TYPO3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @subpackage dlf | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @access public | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  |  **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | class Profile | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * This holds the logger | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * @var LogManager | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * @access protected | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     protected $logger; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * This holds the client | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * @var Client | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      * @access protected | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     protected $client; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      * The raw ORCID profile | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |      * @var \SimpleXmlElement|false | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |      **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     private $raw = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      * Constructs client instance | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |      * @param string $orcid: the ORCID to search for | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     public function __construct($orcid) | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         $this->client = new Client($orcid, GeneralUtility::makeInstance(RequestFactory::class)); | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |      * Get the ORCID profile data | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      * @return array|false | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |     public function getData() | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         $this->getRaw('person'); | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         if (!empty($this->raw)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             $data = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |             $data['address'] = $this->getAddress(); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |             $data['email'] = $this->getEmail(); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |             $data['fullName'] = $this->getFullName(); | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |             return $data; | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |             $this->logger->warning('No data found for given ORCID'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * Get the address | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |      * @return string|false | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |     public function getAddress() | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |         $this->getRaw('address'); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         if (!empty($this->raw)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |             $this->raw->registerXPathNamespace('address', 'http://www.orcid.org/ns/address'); | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             return (string) $this->raw->xpath('./address:address/address:country')[0]; | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |             $this->logger->warning('No address found for given ORCID'); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |      * Get the email | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |      * @return string|false | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |      **/ | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |     public function getEmail() | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |         $this->getRaw('email'); | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |         if (!empty($this->raw)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |             $this->raw->registerXPathNamespace('email', 'http://www.orcid.org/ns/email'); | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |             return (string) $this->raw->xpath('./email:email/email:email')[0]; | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |             $this->logger->warning('No email found for given ORCID'); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |             return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |      * Get the full name | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      * @return string|false | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |      **/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     public function getFullName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->getRaw('personal-details'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         if (!empty($this->raw)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             $this->raw->registerXPathNamespace('personal-details', 'http://www.orcid.org/ns/personal-details'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             $givenNames = $this->raw->xpath('./personal-details:name/personal-details:given-names'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             $familyName = $this->raw->xpath('./personal-details:name/personal-details:family-name'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             return (string) $givenNames[0] . ' ' . (string) $familyName[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $this->logger->warning('No name found for given ORCID'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 135 |  |  |             return false; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 136 |  |  |         } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |      * Get the ORCID part of profile data for given endpoint | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |      * @param string  $endpoint the shortname of the endpoint | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |      **/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     protected function getRaw($endpoint) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $this->client->setEndpoint($endpoint); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         $data = $this->client->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         if (!isset($this->raw) && $data != false) { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 151 |  |  |             $this->raw = Helper::getXmlFileAsString($data); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 152 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 154 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 155 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.