irishdan /
ResponsiveImageBundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the IrishDan\ResponsiveImageBundle package. |
||
| 4 | * |
||
| 5 | * (c) Daniel Byrne <[email protected]> |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE file that was distributed with this source |
||
| 8 | * code. |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace IrishDan\ResponsiveImageBundle\File; |
||
| 12 | |||
| 13 | use Doctrine\ORM\EntityManager; |
||
| 14 | use Doctrine\ORM\EntityManagerInterface; |
||
| 15 | use IrishDan\ResponsiveImageBundle\ImageEntityNameResolver; |
||
| 16 | use IrishDan\ResponsiveImageBundle\ResponsiveImageRepositoryInterface; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Class FileToObject |
||
| 20 | * |
||
| 21 | * @package ResponsiveImageBundle |
||
| 22 | */ |
||
| 23 | class FileToObject |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var EntityManager |
||
| 27 | */ |
||
| 28 | private $manager; |
||
| 29 | private $entityClassName; |
||
| 30 | |||
| 31 | public function __construct(EntityManagerInterface $manager, ImageEntityNameResolver $nameResolver) |
||
| 32 | { |
||
| 33 | $this->manager = $manager; |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | $entityClassName = $nameResolver->getClassName(); |
||
| 36 | $this->entityClassName = $entityClassName; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Fetches and returns the image object based on the file name. |
||
| 41 | * |
||
| 42 | * @param $filename |
||
| 43 | * |
||
| 44 | * @return mixed |
||
| 45 | * @internal param $entityClassName |
||
| 46 | */ |
||
| 47 | public function getObjectFromFilename($filename) |
||
| 48 | { |
||
| 49 | /** @var ResponsiveImageRepositoryInterface $repository */ |
||
| 50 | $repository = $this->manager->getRepository($this->entityClassName); |
||
| 51 | |||
| 52 | if ($repository instanceof ResponsiveImageRepositoryInterface) { |
||
| 53 | $fileObject = $repository->findImageFromFilename($filename); |
||
| 54 | |||
| 55 | return $fileObject; |
||
| 56 | } |
||
| 57 | |||
| 58 | return null; |
||
| 59 | } |
||
| 60 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.