/** * Creates images from local filesystem path * * @param Path $path Path passed by the shell * @param string $filename Filename * @param string $type Media Type * @return Image */ public function fromLocalPath(Path $path, $filename, $type = '') { // Replace backslash by regular slash in file path (otherwise breaks the parser) $filename = str_replace('\\', '/', $filename); $imagePath = $path->getRoot() . DS . $filename; $parts = pathinfo($imagePath); $this->setData(['binary_data' => file_get_contents($imagePath), 'full_path' => $imagePath, 'relative_path' => $path->getDirectory() . DS . $filename, 'file_name' => $parts['filename'], 'file_extension' => $parts['extension'], 'type' => $type]); // Retrieve binary contents $this->setId($this); return $this; }
/** * @covers ::getRoot */ public function test_getRoot_should_return_value_passed_to_constructor() { $paramPath = 'configuration/whatever/whatever2/'; $path = new Path($paramPath, 'whatever', 'rootdir'); $this->assertEquals('rootdir', $path->getRoot()); }