1<?php 2 3/** 4 * 2007-2016 PrestaShop. 5 * 6 * NOTICE OF LICENSE 7 * 8 * This source file is subject to the Open Software License (OSL 3.0) 9 * that is bundled with this package in the file LICENSE.txt. 10 * It is also available through the world-wide-web at this URL: 11 * http://opensource.org/licenses/osl-3.0.php 12 * If you did not receive a copy of the license and are unable to 13 * obtain it through the world-wide-web, please send an email 14 * to license@prestashop.com so we can send you a copy immediately. 15 * 16 * DISCLAIMER 17 * 18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 19 * versions in the future. If you wish to customize PrestaShop for your 20 * needs please refer to http://www.prestashop.com for more information. 21 * 22 * @author PrestaShop SA <contact@prestashop.com> 23 * @copyright 2007-2015 PrestaShop SA 24 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 25 * International Registered Trademark & Property of PrestaShop SA 26 */ 27 28namespace PrestaShop\TranslationToolsBundle\Translation\Extractor; 29 30use Symfony\Component\Finder\Finder; 31 32trait TraitExtractor 33{ 34 protected $defaultDomain = 'messages'; 35 36 /** 37 * @var Finder 38 */ 39 protected $finder; 40 41 /** 42 * @param $domainName 43 * 44 * @return string 45 */ 46 protected function resolveDomain($domainName) 47 { 48 if (empty($domainName)) { 49 return $this->defaultDomain; 50 } 51 52 return $domainName; 53 } 54 55 /** 56 * @param $comments 57 * @param $file 58 * @param $line 59 * 60 * @return array 61 */ 62 public function getEntryComment(array $comments, $file, $line) 63 { 64 foreach ($comments as $comment) { 65 if ($comment['file'] == $file && $comment['line'] == $line) { 66 return $comment['comment']; 67 } 68 } 69 } 70 71 /** 72 * @param $finder 73 * 74 * @return $this 75 */ 76 public function setFinder(Finder $finder) 77 { 78 $this->finder = $finder; 79 80 return $this; 81 } 82 83 /** 84 * @return Finder 85 */ 86 public function getFinder() 87 { 88 if (null === $this->finder) { 89 return new Finder(); 90 } 91 92 return $this->finder; 93 } 94} 95